Anything else I can do to speed up this process?
Anything else I can do to speed up this process?
- Subject: Anything else I can do to speed up this process?
- From: Richard Rönnbäck <email@hidden>
- Date: Tue, 27 Jan 2004 18:14:05 +0100
I am making a script for getting Word and RTF files (and possibly other
types) that has no file suffix.
Iterating through folders or using "entire contents" is not an option, as it
has to be as fast as possible.
As far as I know, the shell command "find" does not search for macintosh
file types or creator types, so I thought the best way would be to search
for files that has no period in them. It is ok should it miss a few oddly
named files.
I am quite pleased with what I have come up with so far what I came up with
so far but I just wanted to hear if there is anything else I do to speed it
up even more.
All suggestions will be much appreciated.
set myFindString to "find /Users/richardr/Documents/ \\! -name \"*.*\" -type
f"
set myFoundFiles to every paragraph of (do shell script myFindString)
set myFileNamesToFilter to {"PkgInfo", "Icon", "log"}
set myOtherFileTypes to {"TEXT", "InDd", "FFIL", "LWFN", "osas", "PDF ",
"XLS ", "pref", "8BPS", "InDb", "InDl", "APPL", "TIFF", "EPSF", "PdfS",
"PrSt", "FMP5", "InCd", "clpt", "ttro", "SLD8", "ilht", "ilma", "????",
"SndS", "OEDB", "OECl", "List", "RULE", "Sigs", "Ncch", "XLS4", "fdrp",
"PICT", "WAFF", "XLS8", "C*DB", "KnDB", "poco", "8BCT", "FMP3", "Vss2",
"LINK", "osax"}
set myFilteredFiles to {}
set myCheckCounter to 0
set myWordFiles to {}
set myUnknownFiles to {}
set myFailedFiles to {}
set AppleScript's text item delimiters to ":"
set myStart to time of (current date) --for measuring performance only
tell application "Finder"
repeat with i from 1 to count of my myFoundFiles
set myFile to (item i of myFoundFiles as POSIX file) as string
--this is to filter out a few known names that will either fail or
slow down
if (last text item of myFile) is in my myFileNamesToFilter then
set end of myFilteredFiles to myFile
else
try
--checking against the predefined list is faster that
accessing the file type so this is just to narrow down possible types
if (file type of (alias myFile)) is not in my
myOtherFileTypes then
set myCheckCounter to myCheckCounter + 1
--checking for most likely condition first
if (file type of (alias myFile) = "W8BN" or "RTF") then
set end of myWordFiles to myFile
else if (creator type of (alias myFile) = "MSWD") then
set end of myWordFiles to myFile
else
set end of myUnknownFiles to myFile
end if
end if
on error
set end of myFailedFiles to myFile
end try
end if
end repeat
end tell
set theFinish to time of (current date)
set AppleScript's text item delimiters to ""
set theTime to theFinish - myStart
_______________________________________________
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.
- Follow-Ups:
- Test
- From: Bill Planey <email@hidden>