Applescript to stuff and move files

Joined
Mar 28, 2006
Messages
198
Reaction score
5
We have Stuffit Deluxe 7.0.3. We're running Mac OS X. I know how to make a script that moves files to specific folders based on file names... what I want is to have PDFs stuffed to .sit files individually (one .sit for every .pdf) as they are put into a specific folder and then move the original PDF to one folder and the SIT to another folder. Like I said, the moving part works... it's the stuffing part that's being uncooperative...
Here's what I've got... I put several PDFs in my "inFolder" for testing purposes...
it gives me the error message of "Can't get item 1 of "Nicodemus:TestfolderIn""

property inFolder : "Nicodemus:TestfolderIn"
property outfolder : "Nicodemus:TestfolderOut"
property notfolder : "Nicodemus:TestfolderNot"

on idle
tell application "Finder"
set theCount to (count of items of inFolder)
repeat until theCount = 0
if exists item 1 of folder inFolder then
set x to name of item 1 of folder inFolder
if x contains ".PDF" then
select item 1 of inFolder
tell application "System Events"
tell process "Stuffit Deluxe"
keystroke "s" using command down
delay 1
end tell
end tell
move item 1 of folder inFolder to folder outfolder with replacing
else if x contains ".sit" then
move item 1 of folder inFolder to folder notfolder with replacing
end if
else if not (exists item 1 of folder inFolder) then
return 0
end if
end repeat
end tell
return 10
end idle
 

Ric

Joined
May 14, 2004
Messages
4,260
Reaction score
5
Hi there,

unless anyone else jumps in... (Feel free !)

I would go back to stage 1

Code:
tell application "Finder"
	
	set inFolder to folder "Test In Folder" of desktop
	set theFiles to every file of inFolder
	
	repeat with aFile in theFiles
		--do stuff !
		tell application "Finder"
			if the name extension of aFile is "PDF" then
				--do more stuff !
				beep
			end if
		end tell
	end repeat
	
end tell

I'll have a better look later...

regards

Ric
 
Joined
Mar 28, 2006
Messages
198
Reaction score
5
I've been working on this off and on for a while and I have something that works... sort of anyway... I've got a DropBox that I created with Stuffit Express PE... it takes whatever files are dropped on it or opened with it and stuffs the to .sit files, which is exactly what I want it to do. But... our file sizes range from 200K to 100+MB, so I built in a delay to give the files time to be stuffed before they were moved... here's how it is right now, and it works...

property inFolder : "Godzilla: PDFs for printers:North:printed/ready to stuff:"
property notfolder : "Godzilla: PDFs for printers:North:TPN Sent PDFs:"
property outfolder : "Godzilla: PDFs for printers:North:Stuffed/ready to send:"


on idle
tell application "Finder"
set theCount to (count of items of inFolder)
repeat until theCount = 0
if exists item 1 of folder inFolder then
set x to name of item 1 of folder inFolder
if x contains "sit" then
move item 1 of folder inFolder to folder outfolder with replacing
else if x contains "pdf" then
open item 1 of folder inFolder using application file "Drop Box" of folder " PDFs for printers" of disk "Godzilla"
delay 500
move item 1 of folder inFolder to folder notfolder with replacing
end if
else if not (exists item 1 of folder inFolder) then
return 0
end if
end repeat
end tell
end idle

BUT... it means that it waits 8.33333 minutes for every file, which is a waste of time for the smaller files... so, I've been working on telling it to wait different time periods based on data size... see below

property inFolder : "Godzilla: PDFs for printers:North:printed/ready to stuff:"
property notfolder : "Godzilla: PDFs for printers:North:TPN Sent PDFs:"
property outfolder : "Godzilla: PDFs for printers:North:Stuffed/ready to send:"


tell application "Finder"
set theCount to (count of items of inFolder)
repeat until theCount = 0
if exists item 1 of folder inFolder then
set x to name of item 1 of folder inFolder
if x contains "sit" then
move item 1 of folder inFolder to folder outfolder with replacing
else if x contains "pdf" then
open item 1 of folder inFolder using application file "Drop Box" of folder " PDFs for printers" of disk "Godzilla"
get data size of item 1 of folder inFolder
if (data size of item 1) < 1500000 then
delay 90
else if (data size of item 1) > 1500000 and (data size of item 1) < 5000000 then
delay 200
else if (data size of item 1) > 5000000 and (data size of item 1) < 10000000 then
delay 250
else if (data size of item 1) > 10000000 and (data size of item 1) < 20000000 then
delay 300
else if (data size of item 1) > 20000000 and (data size of item 1) < 30000000 then
delay 350
else if (data size of item 1) > 30000000 and (data size of item 1) < 40000000 then
delay 400
else if (data size of item 1) ? 40000000 then
delay 600
end if
move item 1 of folder inFolder to folder notfolder with replacing
end if
else if not (exists item 1 of folder inFolder) then
return 0
end if
end repeat
end tell

but it doesn't exactly work... it's great for the smaller files I've tested (up to about 23MB), but anything over that I get an error... specifically it says, "AppleScript Error: application "Finder" got an error: "\"The operation could not be completed because some items had to be skipped. "001_TPN Sep06 4C.pdf.sit"/""... which is logical of course, because just before this message occurs it moves the pdf "001_TPN Sep06 4C.pdf" to the designated "notFolder" and the sit file is not finished being stuffed... So, if anyone can enlighten me on what's wrong with the data size part that would be great... or, if anyone has a suggestion to make the script smart enough to simply wait until "DropBox" has completed its task and uses that as a cue to continue with the next step in the script...
Zeyhra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top