Get every file of the entire contents of a folder. Quickly.
Get every file of the entire contents of a folder. Quickly.
- Subject: Get every file of the entire contents of a folder. Quickly.
- From: Paul Skinner <email@hidden>
- Date: Mon, 13 Oct 2003 16:57:03 -0400
In trying 'entire contents of' and Satimage's 'list files' I am left
unsatisfied. I won't even try recursing the directories in AppleScript.
Satimage OSAX 2.5.5 won't go recursive OMM even though that is the
default, and 'entire contents of' is SO SLOW! So here's my current
solution. I think it runs at 'Ludicrous speed'. Returning 4960
unfiltered files in less than four seconds on my 667 PB G4, although I
can't compare it to Satimage due to the later's refusal to perform.
Can you break it? Offer improvements?
EveryFileOfFolder(choose folder)
EveryFileOfFolder({choose folder, "jpg"})
on EveryFileOfFolder(parameters)
set prevDelim to AppleScript's text item delimiters
set searchterm to ""
repeat with thisItem in (parameters as list)
try
set folderPath to ((thisItem as text) as alias)
on error
set searchterm to (thisItem as text)
end try
end repeat
set AppleScript's text item delimiters to ":"
set DiskName to return & text item 1 of (folderPath as text)
set AppleScript's text item delimiters to ""
set folderPath to quoted form of (POSIX path of folderPath)
try
set filelist to {}
if searchterm is not "" then
set filelist to (paragraphs of (do shell script "find " & folderPath
& " ! -name '\\.*' -type f | tr -s '//' | tr '/' ':' | grep " &
searchterm))
else
set filelist to (paragraphs of (do shell script "find " & folderPath
& " ! -name '\\.*' -type f | tr -s '//' | tr '/' ':'"))
end if
end try
if filelist is {} then
set AppleScript's text item delimiters to prevDelim
return filelist
end if
set AppleScript's text item delimiters to DiskName
set filelist to (DiskName & (filelist as text) as Unicode text)
set AppleScript's text item delimiters to return
set filelist to paragraphs 2 thru -2 of filelist
set AppleScript's text item delimiters to prevDelim
return filelist
end EveryFileOfFolder
PS
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.