Re: List content of a folder, output to document
Re: List content of a folder, output to document
- Subject: Re: List content of a folder, output to document
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 6 Jan 2010 12:37:51 -0500
On Wed, Jan 6, 2010 at 12:18 PM, email@hidden <email@hidden> wrote:
>>
>> However you get the start folder, if all you want to do with the list
>> is write it to a text file, you might as well let the shell do that
>> part, too.
>>
>> do shell script "find " & (quoted form of POSIX
>> path of theFolder) & " ! -name '.*' -print >" & (quoted form of POSIX
>> path of theTextFile)
>
> This is returning the full path for each file. The OP did not want the path to the folder itself
> included, so an extra step is needed to remove the path to the folder for each item.
Ah, missed that, sorry.
>>> This is what i hope to get in the file:
>>>
>>> /index.html
>>> /subfolder1/image.jpg
>>> /file2.txt
>>> /subfolder2/subsubfolder1/meta.qsl
Not a fan of a leading slash that makes the list look like absolute
pathnames if they're actually relative ones. I'd use "./" instead:
./index.html
./subfolder1/image.jpg
or no leading directory at all:
index.html
subfoder1/image.jpg
> Plus, the shell script also provides the contents of application bundles which is probably not wanted. Any way to avoid that?
If you can identify application bundles by name (for instance, assume
they're all named *.app), sure:
do shell script "cd " & (quoted form of POSIX path of theFolder) & "
&& find . \\( -name '*.app' -prune -o ! -name '.*' \\) -print >" &
(quoted form of POSIX path of theTextFile)
That is: find everything that is either named '*.app' (in which case
prune the search there, meaning if the *.app file is a folder, don't
descend into it), or else not named '.*' (no pruning here), and print
out the name.
Change the "find ." to "find *" if you want the version without "./"
in front of the relative pathnames. If you're dead set on the leading
"/", use the "find ." version and add a pipe through sed:
do shell script "cd " & (quoted form of POSIX path of theFolder) & "
&& find . \\( -name '*.app' -prune -o ! -name '.*' \\) -print | sed -e
's/^\\.//' >" & (quoted form of POSIX path of theTextFile)
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden