Below is my script but I am getting error in opening a file please put some light on it.
tell application "Finder"
set thePath to (choose folder) as text
set FilesList to files in thePath as list
set HDPath to the startup disk
set HDPath to HDPath as string
set outfolder to the HDPath & "BJT2EPS Conversion:TempFiles:"
set outfolder to outfolder as string
end tell
repeat with aFile in FilesList
set theFile to aFile
tell application "Adobe Photoshop 7.0"
open theFile
end tell
end repeat
this doen’t work, because “files of” needs a file reference or an alias.
set thePath to (choose folder) as text
set FilesList to files in thePath as list
The open command in PhotoShop works with open file [string]
I would do it like this:
tell application "Finder"
set FilesList to files of (choose folder)
set HDPath to the startup disk as string
set outfolder to the HDPath & "BJT2EPS Conversion:TempFiles:"
end tell
repeat with aFile in FilesList
tell application "Adobe Photoshop 7.0"
open file (aFile as string)
end tell
end repeat
set inputFolder to choose folder with prompt "Blah blah blah" without invisibles
--
tell application "Finder"
set filesList to files in inputFolder
set HDPath to the startup disk as string
set outputFolder to HDPath & "BJT2EPS Conversion:TempFiles:" as string
end tell
repeat with aFile in filesList
tell application "Finder"
set theFile to aFile as alias
end tell
tell application "Adobe Photoshop 7.0"
activate
open theFile
set docRef to the current document
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (outputFolder as string) & docBaseName
tell docRef
-- Do your stuff here
-- Save with your options
save docRef in file newFileName as JPEG with options ¬
{quality:9} appending lowercase extension with copying
end tell
close docRef without saving
end tell
end repeat
--
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName
set inputFolder to choose folder with prompt "Please choose the folder containing Images" without invisibles
tell application "Finder"
set filesList to files in inputFolder
set HDPath to the startup disk as string
set outfolder to the HDPath & "BJT2EPS Conversion:TempFiles:" as string
end tell
repeat with aFile in filesList
tell application "Finder"
set theFile to aFile as alias
end tell
tell application "Adobe Photoshop 7.0"
open theFile
tell front document
do script "DoSave2EPS"
end tell
end tell
end repeat
--quit application "Adobe Photoshop 7.0"
tell application "Finder"
set moveoutfolder to the HDPath & "BJT2EPS Conversion:TempFiles:" as string
set these_folder to every file of moveoutfolder
repeat with each_file in moveoutfolder
-- open folder inputFolder
tell application "Finder" to move each_file to inputFolder with replacing
end repeat
-- move file moveoutfolder to folder inputFolder with replacing
end tell
But i am getting a problem, I am not able to move file from one location to another specially in this program. Please help me in this.
tell application "Finder"
set moveoutfolder to the HDPath & "BJT2EPS Conversion:TempFiles:"
set these_folder to every file of (moveoutfolder as alias)
repeat with each_file in folder moveoutfolder
tell application "Finder" to move each_file to inputFolder with replacing
end repeat
But I am getting an error and the error is given below
Infact, it is moving three item to the desired loaction but, unable to move item 4, I don’t know why it is happening.
tell application "Finder"
set HDPath to the startup disk as string
set moveoutfolder to HDPath & "BJT2EPS Conversion:TempFiles:"
set moveoutfolder to moveoutfolder as alias
move every file of moveoutfolder to (choose folder) with replacing -- choose folder being "inputfolder"
end tell
You might want to put your repeat loop back in if thats used later in your script for something but this
was working for me…
when you (re)move the first item from the source folder, the internal repeat counter will fail,
because there is one item less in the folder (and so on).
To avoid this error, use a variable instead of accessing the folder directly
tell application "Finder"
set moveoutfolder to the HDPath & "BJT2EPS Conversion:TempFiles:"
set these_folder to every file of (moveoutfolder as alias)
repeat with each_file in these_folder
move each_file to inputFolder with replacing -- Finder is already targeted
end repeat