I cant understand why this script wont stop repeating? I think the problem lies in the text
set ContactSheet to ""
repeat until ContactSheet = 0
here’s the full script…
on adding folder items to StartFolder after receiving these_items
tell application "Adobe Photoshop CS"
do action "ContactSheet" from "TestSet"
end tell
tell application "Adobe Photoshop CS"
set ContactSheet to ""
repeat until ContactSheet = 0
do action "FlattenSaveClose" from "TestSet"
end repeat
end tell
tell application "Finder"
try
set filesTocopy to every file of StartFolder
repeat with aFIle in filesTocopy
move aFIle to folder (alias "Macintosh HD:Users:geoffsmith:Desktop:Jpegs:")
end repeat
on error the errormessage number the errornumber
set the errortext to "Error: " & the errornumber & ". " & the errormessage
display dialog the errortext & return & ¬
"Return to Script.... SOMETHINGS MESSED UP!!" buttons {"OK"} default button 1
return the errortext
end try
try
set subFolders to (every folder of StartFolder)
repeat with aFolder in subFolders
move aFolder to folder (alias "Macintosh HD:Users:geoffsmith:Desktop:Jpegs:")
end repeat
on error the errormessage number the errornumber
set the errortext to "Error: " & the errornumber & ". " & the errormessage
display dialog the errortext & return & ¬
"Return to Script.... SOMETHINGS MESSED UP!!" buttons {"OK"} default button 1
return the errortext
end try
end tell
end adding folder items to
The problem i’m having is that it wont go past the contact sheet stage so it wont move on to the next step
can anyone help at all
Pleeeeease this thing is driving me insane!!!
Many Thanks
Jax
Model: iBook G4
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
you set ContactSheet to “” , which is text and then you have the repeat action asking for ContactSheet to be 0, a number and I don’t see where you change the value of ContactSheet. Maybe something like this
set ContactSheet to 1
repeat until ContactSheet = 0
do action "FlattenSaveClose" from "TestSet"
if some action is something else then -- a test to know that your actions have been completed
set ContactSheet to 0
end if
end repeat
Another question is why do you need a repeat at this point? Are there several documents open that are supposed to have these actions performed on?
The line in the script that I offered that is giving an error is where you would put a test of your design. It was not intended to be the actual code.
Looking at your code it looks as though your action in photoshop closes the document after it is closed. You could do something like this
set ContactSheet to 1
tell application "Adobe Photoshop CS"
repeat until ContactSheet is 0
do action "FlattenSaveClose" from "TestSet"
if (count (open documents)) is 0 then set ContactSheet to 0
end repeat
end tell
Another question. Your script is setup as a folder action. Are the open documents in Photoshop supposed to be opened by the script or are there other files that are already opened that you want these actions performed on?
PreTech
–I meant to say “Looking at your code it looks as though your action in photoshop closes the document after it is performed.”
I wanted the script to be part of a workflow that enables me to drop files into a certain folder. i.e “Start Folder”
The “Start Folder” would…
open photoshop
create a contact sheet
flatten the images
save and close the contact sheets to a specific folder i.e Contact Folder
I want it to repeat with all open documents (which would vary each time)
then have finder send the original files (once the action is complete) to a different specific folder ie. Original Folder
I then have another script attached the Contact Folder to print then move to a Printed Folder.
So i end up with a Folder showing me which files have been sent through the workflow, plus an end result “Printed Folder” with all my printed Contact Sheets.
So far so good!!
now i just have to figure out how to write a script that will rename the files as they come into the “Printed Folder”.
Any ideas are overly welcome
Many Thanks
Jax
Model: iBook G4
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)
tell application "Finder"
set theC to folder "YourHardDrive:Users:yourUserName:Desktop:yourFolderName:" -- this line should be set to the path to your folder. This example shows a folder that would be on your desktop.
set astid to AppleScript's text item delimiters -- this saves the text item delimiters that AS uses.
set AppleScript's text item delimiters to "." -- this changes the delimiters so the extension can be separated from the name.
repeat with anItem in theC
if class of anItem is document file then
set theName to name of anItem
set fName to first text item of theName
set lName to last text item of theName
set newName to fName & "Printed." & lName -- this would be whatever you wanted to name your file. Note the period after the Printed. This replaces the "." so your file name is correct.
set name of anItem to newName
end if
end repeat
set AppleScript's text item delimiters to astid
end tell
That kinda worked…
I tried attaching the script onto my folder, but it looped so i ended up having file names with the name repeated and repeated i.e it would start with ContactSheet001Printed.jpg but after about 3mins i would have ContactSheet001PrintedPrintedPrintedPrintedPrintedPrinted etc etc
on adding folder items to PrintedContacts after receiving these_items
tell application "Finder"
set theC to folder (alias "Macintosh HD:Users:geoffsmith:Desktop:PrintedContacts:") -- this line should be set to the path to your folder. This example shows a folder that would be on your desktop.
set astid to AppleScript's text item delimiters -- this saves the text item delimiters that AS uses.
set AppleScript's text item delimiters to "." -- this changes the delimiters so the extension can be separated from the name.
repeat with anItem in theC
if class of anItem is document file then
set theName to name of anItem
set fName to first text item of theName
set lName to last text item of theName
set newName to fName & "Printed." & lName -- this would be whatever you wanted to name your file. Note the period after the Printed. This replaces the "." so your file name is correct.
set name of anItem to newName
end if
end repeat
set AppleScript's text item delimiters to astid
end tell
end adding folder items to
Do you know of a way that it would recognise if i put numbers in so that it would make them sequential?
It took me a while to figure out what was going on. You have this in a folder action script. So you add files to the folder, then the script changes the file as soon as it gets there. The items in the folder changed and so the script kicks in and renames the files again and again and again and again and again. You should rename the files before they are moved to this folder.
Or, if you are going to rename files in the folder action script then keep a running list of the files in the folder, put the renamed file on it, and check whether the list contains that file name before doing anything else.
What i’m looking for is a script that will remember the items contained in the folder, so that when a new file is added it will only change the name of the new file to make it sequential to the files already in the folder.
The problem is caused by the Photoshop action “Contact Sheet” which everytime a new bunch of files are contact sheeted they automatically start from “ContactSheet001.jpg”
As part of my workflow the files are to be dropped after contact sheeting into a print folder then into a printed archive folder.
I cant find a way of making Photoshop keep the filenames sequential so i think i have to do this in the printed archive folder?
property _prefs : {foo:1, bar:"hello"}-- [a record containing your persistent preferences]
on _prefsFile()
return POSIX file (POSIX path of (path to preferences) & "MyAppletPrefs") -- [your prefs filename here]
end _prefsFile
on loadPrefs()
try
set _prefs to read _prefsFile() as record
on error number -43 -- file not found; use default values
end try
end loadPrefs
on savePrefs()
set f to open for access _prefsFile() with write permission
write _prefs to f as record
close access f
end savePrefs
I use my version of this to keep a record of update events in a preference file so they don’t have to be kept in the script itself.
Hi Apologies for the late response i have been away and I’m still trying to get to the bottom of this…
Thanks but I’m not too sure how i can get the the prefs script to work with what i’m trying to achieve maybe i’m looking ta it wrong??..
i basically want some form of sequential numbering really
I’ve tried this script courtesy of Jean-Baptiste Le STANG…
on adding folder items to this_folder after receiving thoose_files
set defaultname to "Contact"
set leadingzeros to 3
set fileExtension to ".jpg"
tell application "Finder"
try
set z to count (file in thoose_files whose name contains defaultname)
on error
set z to 0
end try
try
set y to count (files in this_folder whose name contains defaultname)
on error
set y to 0
end try
repeat with x from 1 to count thoose_files
set argumentnumber to (x + y - z - 1) as string
tell application "Finder"
repeat until (count (argumentnumber)) > leadingzeros - 0
set argumentnumber to "0" & argumentnumber
end repeat
end tell
set name of item x of thoose_files to defaultname & argumentnumber & fileExtension
end repeat
end tell
end adding folder items to
which works ok when i only drop 1 document in at a time but if i try to drop 2 in it doesnt like it?
Is this because the FA is still renaming as the files are dropping in do you think? thats why it’s missing some if so is there a way around this?