I am working on a script to process images with PS
Th only problem is that it will not pick up a single file
probably something to do with:
set listFiles to (files of entire contents of processFolder) as alias list
repeat with thisFile in listFiles
Any suggestions?
Here the full script:
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder"
if not (exists folder "LAY_OUT" of processFolder) then
make new folder at processFolder with properties {name:"LAY_OUT"}
end if
set the destination_folder to folder "LAY_OUT" of processFolder as alias
end tell
tell application "Finder"
set listFiles to (files of entire contents of processFolder) as alias list
repeat with thisFile in listFiles
tell application "Adobe Photoshop CS2"
with timeout of 300 seconds
activate
set display dialogs to never
set UserPrefs to properties of settings
set ruler units of settings to pixel units
open thisFile
tell current document
if (bits per channel is sixteen) then set bits per channel to eight
resize image resolution 72 resample method bicubic
set docName to name
set newFileName to (destination_folder as string) & docName & ".lay"
save in file newFileName as Photoshop EPS appending no extension with options {class:EPS save options, embed color profile:false, encoding:high quality JPEG, preview type:eight bit TIFF}
close without saving
tell application "Finder" to move thisFile to destination_folder with replacing
end tell
end timeout
end tell
end repeat
end tell
keeping your construction you need to add an error handler
try
tell application "Finder" to set listFiles to (files of entire contents of processFolder) as alias list
on error
tell application "Finder" to set listFiles to (files of entire contents of processFolder) as alias as list
end try
leave the list as file specifier and coerce thisFile to an alias when necessary
...
set listFiles to (files of entire contents of processFolder)
...
open (thisFile as alias)
...
the fastest method is to grab the data with the shell find command
set processFolder to choose folder with prompt "Choose a folder that contains images to process"
tell application "Finder"
if not (exists folder "LAY_OUT" of processFolder) then
make new folder at processFolder with properties {name:"LAY_OUT"}
end if
set the destination_folder to folder "LAY_OUT" of processFolder as alias
end tell
set listFiles to paragraphs of (do shell script "find " & quoted form of POSIX path of processFolder & " -type f ! -name '.*'") -- finds all files (except folders and files starting with a dot)
repeat with i in listFiles
set thisFile to POSIX file i as alias
tell application "Adobe Photoshop CS2"
with timeout of 300 seconds
activate
set display dialogs to never
set UserPrefs to properties of settings
set ruler units of settings to pixel units
open thisFile
tell current document
if (bits per channel is sixteen) then set bits per channel to eight
resize image resolution 72 resample method bicubic
set docName to name
set newFileName to (destination_folder as string) & docName & ".lay"
save in file newFileName as Photoshop EPS appending no extension with options {class:EPS save options, embed color profile:false, encoding:high quality JPEG, preview type:eight bit TIFF}
close without saving
tell application "Finder" to move thisFile to destination_folder with replacing
end tell
end timeout
end tell
end repeat
Thanks!
The last option with a shell script looks the best and works. The only thing is that the subfolder called LAY-OUT should also be excluded.
How do I change this?
My UNIX knowledge for such nested commands is very poor, maybe somebody knows to inlude the exception
into the shell line, so I would filter the paths with
...
repeat with i in listFiles
if i does not contain "LAY_OUT" then
set thisFile to POSIX file i as alias
...
Hi Stevan,
I will check your suggestion next monday
Thanks so far
Just thinking…
A droplet instead of choosing the folder of files might solve the problem