Re: slow moving
Re: slow moving
- Subject: Re: slow moving
- From: Nigel Garvey <email@hidden>
- Date: Thu, 30 Nov 2000 01:45:09 +0000
John McAdams wrote on Wed, 29 Nov 2000 15:30:42 -0700:
>
Below is a little script I wrote to sort through a bunch of dropped
>
folders and combine like files together in a central folder. But it
>
is slooooow. Does anybody recommend another way for moving files
>
around.
>
--test folder names and move files
>
on move_foldContents(parent_folder)
>
tell application "Finder"
>
set sub_folds to every folder of parent_folder
>
repeat with i in sub_folds
>
if name of i ends with "100-D" or name of i
>
ends with "100-F" then
>
if (count of every file of i) > 0 then
>
move every file of i to
>
Combined_100 with replacing
>
end if
>
else if name of i ends with "120-D" or name
>
of i ends with "120-F" then
[etc]
The main culprit seems to be reading the folders' names every time. Just
read them once into a variable and use that for the string comparisons.
(I've used just the last 5 characters below, but the main speed
difference will be in not having to get the names from the folders
several times over.) Also, you don't need to count the contents of a
folder to see if it contains files. If there are no files, they simply
won't be moved. So:
--test folder names and move files
on move_foldContents(parent_folder)
tell application "Finder"
set sub_folds to every folder of parent_folder
repeat with i in sub_folds
set fdr_name to name of i
if (count fdr_name) >= 5 then
set name_end to text -5 thru -1 of fdr_name
if name_end is in {"100-D", "100-F"} then
move every file of i to Combined_100 with replacing
else if name_end is in {"120-D", "120-F"} then
move every file of i to Combined_120 with replacing
else if name_end is in {"150-D", "150-F"} then
move every file of i to Combined_150 with replacing
else if name_end is in {"280-D", "280-F"} then
move every file of i to Combined_280 with replacing
else if name_end is in {"335-D", "335-F"} then
move every file of i to Combined_335 with replacing
end if
end if
end repeat
end tell
end move_foldContents
NG