[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] searching directories



Well, I issue simple $resp = `cd`; and ls commands with backtics under unix
systems.
Do an ls at your starting directory, pulling the result into file and
directory hashes:
   key=returned line
   value = full path to this level
Then expand the lines in your dir hash. By cd'ing to each and ls'ing in
turn adding to the file hash.
I build a file list tracing all the way down the directory tree tossing the
directory
entires as they are explored.
If you want only specific files like ".txt" files than compare and toss as
needed.
Use the returned file list to do whatever to all gathered files.
There are probably flavors of find that do this.

Not all "unix'ish" machines support switches like -R1 (recursive, one file
per line).
This process can be made multiplatform by changing cd and ls, $` and the
path delimiter per OS.


>Dear sir,
>
>Please could you advise me as a newcomer to Perl. I am trying to gather
>documents from a variety of directories, some deeply nested. Once I have
>the files I then propose to copy them somewhere else and maybe export
>the data into filemaker or something like that. I realise that it may be
>achievable by applescript but so far, I have not enjoyed using this
>method!
>
>Could you point me out to some sample perl code that might help? I would
>expect that I need a subroutine or function that will be called if a
>certain file is a directory. I understand how to do a basic list for one
>level but am stuck as to how to go say 5 levels deep.
>
>Many thanks for your assistance.
>
>
>Mark Bedish
>
>
>
>===== Want to unsubscribe from this list?
>===== Send mail with body "unsubscribe" to macperl-request@macperl.org


--
Fred Giorgi <mailto:fgiorg@atl.com>




===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org