Mac Help Forums


Reply
Thread Tools Display Modes

Applescript to stuff and move files

 
Senior Member
zeyhra's Avatar
Join Date: Mar 2006
Location: Santa Cruz, California
Posts: 198
 
      12th June 2006
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
 
Reply With Quote
 
 
 
 
Senior Member
zeyhra's Avatar
Join Date: Mar 2006
Location: Santa Cruz, California
Posts: 198
 
      28th July 2006
Anyone got any suggestions for this one?
 
Reply With Quote
 
Ric Ric is offline
Senior Member
Ric's Avatar
Join Date: May 2004
Posts: 4,260
 
      28th July 2006
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
 
Reply With Quote
 
Senior Member
zeyhra's Avatar
Join Date: Mar 2006
Location: Santa Cruz, California
Posts: 198
 
      10th August 2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
applescript help move files after converting. aaabha AppleScript 0 14th March 2011 04:11 AM
Applescript to delete and move files appatight AppleScript 0 9th March 2011 09:46 PM
AppleScript wanted to move frontmost (Finder/Application) to e.g.left, right, top, bottom Otto van Verseveld Apps 5 8th April 2008 10:24 PM
applescript help move files after converting polites AppleScript 0 19th March 2007 09:08 AM
AppleScript to move or hide OS X dock when specific app in foreground? Edward Mendelson AppleScript 0 23rd February 2004 01:01 AM


All times are GMT +1. The time now is 04:16 AM.
Mac-Help.com is an independent website and is not affiliated with Apple Inc.


Welcome!
Welcome to the Mac Help Forums
 


Latest Threads
Yikes! Teacher needs help!
Mollyc4627 (7 Hours Ago, 08:57 PM)

Unable to log in to websites
AMonty20 (10 Hours Ago, 05:52 PM)

Add Different Speech Commands
bae_22 (11 Hours Ago, 04:40 PM)

Login (2 macs) passwords spontaniously changed?
Roger Vaught (12 Hours Ago, 03:31 PM)

Best car charger or inverter for Macbook Pro?
imeme87 (12 Hours Ago, 03:22 PM)

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51