Re: AppleScript-Users Digest, Vol 6, Issue 153
Re: AppleScript-Users Digest, Vol 6, Issue 153
- Subject: Re: AppleScript-Users Digest, Vol 6, Issue 153
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 31 Mar 2009 11:33:32 -0700
- Thread-topic: AppleScript-Users Digest, Vol 6, Issue 153
>>> Is there other ways to write the Applescript to watch for a file to make
sure the file is completely copied before moving or is there another solution
that would work better than Applescript?
This script got me thinking and since I have a script that does basically
the same thing I took another look at it and made it run a bit faster.
In this version, rather than wait 3 seconds for each file move, the script
gets the list of files and sizes, waits 3 seconds just once, then processes
the entire list.
The advantages are there is only 1 3-second delay and if there are more than
1 files the subsequent files get the benefit of the time involved in copying
the previous files.
Also I tidied up the OP script. The first if/then wasn't needed, if there
are no items in the list the repeat loop won't run.
Repeat loop for the duplicate/move portion needed something. Move only
removes the file if it resides on the same volume and the script as written
could keep moving the same files over and over.
HTH
ES
property strDest1 : "VolumeDestination:FolderA:"
--property strDest2 : " VolumeDestination:FolderB:"
--property strDest3 : " VolumeDestination:FolderC:"
--property strDest4 : "QLA_SuitCase:Misc:DisTiller Watched:<Email Address
Goes Here>:"
--path to the folder you are watching
property strSource : " VolumeSource:FolderA:InComingFolder:"
property intWait : 600 --how long between checks
on idle
set lisFiles to list folder strSource without invisibles
repeat with i from 1 to count lisFiles
set thisPath to (strSource & (item i of lisFiles)) as string
tell application "Finder" to set the end of filesToMove to
{thisPath, the size of file thisPath}
end repeat
delay 3
repeat until filesToMove = {}
set filesToMove to moveFiles(filesToMove)
end repeat
return intWait
end idle
on moveFiles(filesToMove)
set filesNotReady to {}
repeat with fileInfo in filesToMove
tell application "Finder"
copy fileInfo to {thisPath, previousSize}
try
set newSize to size of file thisPath
if newSize = previousSize then
repeat with i in {strDest1}
--duplicate file thisPath to folder (i as string)
with replacing
duplicate file thisPath to folder (i as string)
--
end repeat
delete file thisPath
else
set the end of filesNotReady to {thisPath, the size of
file thisPath}
end if
on error err
end try
end tell
end repeat
return filesNotReady
end moveFiles
_______________________________________________
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