Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thriftinkid

macrumors regular
Original poster
Mar 24, 2008
119
0
I have the following scripts that work individually, but I have hit a snag though when using them. Because of a snag in the software I'm using, I basically I have to fuse the two together to accomplish the following:

1. Check application to see if it is done processing
2. If done, check folder size of myFolder (see if it is still copying data)
A) If yes- Check application to see if it is done processing (Or repeating step one)
B) If no- end repeat and move on.

This basically has to be done because if I am running a process on multiple items, once the first one is done, the script moves on because it reads the first item is done processing.

So basically it looks like I need two repeat command scripts like below written in a bigger repeat command script, correct?

To check if the application is done processing:

Code:
tell application "Cleaner 6.5.1" to Start encoding Destination "myFolder"
	repeat
		if not check_cleaner_is_compressing() then exit repeat
	end repeat
end timeout

to check_cleaner_is_compressing()
	delay 3
	tell application "Cleaner 6.5.1"
		set theEncoderStatus to GetEncoderStatus
		return (ProcessingState of theEncoderStatus is ProcessRunning)
	end tell
end check_cleaner_is_compressing

To check if the files are done copying:

Code:
set myFolder to ((path to desktop folder as text) & "myFolder:")
tell application "Finder" to set theFiles to files of folder myFolder
repeat with oneFile in theFiles
   repeat until checkStableSize(oneFile)
   end repeat
end repeat
say "done"

on checkStableSize(myFile)
   set f to quoted form of POSIX path of (myFile as alias)
   set sizeThen to first word of (do shell script "du -d 0 " & f)
   delay 2 -- seconds (set to longer if needed)
   set sizeNow to first word of (do shell script "du -d 0 " & f) as integer --coercing to integer fixes the quote problem
   return (sizeNow - sizeThen = 0)
end checkStableSize
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.