Re: Slow Moving Files?
Re: Slow Moving Files?
- Subject: Re: Slow Moving Files?
- From: Andrew Oliver <email@hidden>
- Date: Sat, 25 Jan 2003 04:53:32 -0800
The first thing that comes to mind is that most of the time in this script
is likely to be spent building the list of folders.
I don't think you need to, though.
I think I'm right in saying you should be able to do something like:
try
repeat
set this folder to folder 1 of disk "disk name" -- or folder "folder name,
depending on where you're starting from
-- parse the folder name
-- and move it
end repeat
on error
-- all done
end try
As long as the move code moves the folder to a different directory tree, the
next iteration through the loop will find a different folder - i.e. what was
folder 2 before becomes folder 1 on the next iteration.
In this way you don't need to pre-build the list of folders, and enclosing
the whole thing in a try/end try statement means it will keep running until
an error is generated - clearly it is hoped that the error would be "can't
get folder 1...", meaning there are no more folders, but you might want to
add additional error handling in case other errors occur (e.g. can't
move/rename a locked folder, error in parsing the folder name (can't get
character 9 of "filename"), etc., etc.
Note: I'm basing this on the assumption that asking for folder 1 doesn't
require a complete list of folders to be built first - if that's the case
this code will be much slower since it'll build the list on every iteration.
Since I don't have enough folders on my disk to notice any difference
between the two methods, I'll leave it up to you to confirm this. :)
Andrew
:)
On 1/24/03 5:30 PM, "Stephen Swift" <email@hidden> wrote:
>
I wrote a script for a friend who had about 10,000 folders somewhere and
>
needed them to be moved to other folders on the same disk based on the name
>
of the folder, so I wrote a script that did this (pardon my
>
AppleScriptenglish):
>
>
Set list1 to every folder (that took some time)
>
Repeat with I in list1
>
Get name of folder
>
Get 9th character of name
>
Get 7 & 8 characters of name
>
Move folder to alias "somelocation:9:78:"
>
--the 9 and 78 are the character numbers, not an actual location
>
End repeat
>
>
I tested the script, and it took almost half an hour! Now I know I'm
>
working with 10,000 folders here, and it would have taken much longer by
>
hand... But, is this normal? Or maybe there was a better way. I was also
>
wondering if there was a limit on how many items could be put in a list. If
>
he had 15,000 items, would the list max out at 12,000 for example? Thanks a
>
bunch.
>
>
Stephen Swift
>
_______________________________________________
>
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.
_______________________________________________
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.