I need to do the following for every file that ends with “_tn”
add “tn_” to the begining of the name
2)remove “_tn” from the end of the name and retain the extension.
Example “image_001_tn.jpg” would turn into “tn_image_001.jpg”.
Here is a sample: ( The begining just creates some variables based off the selected folder )
choose folder with prompt "Choose a job folder to proof to the web:"
set jobFolder to result
set button_pressed to ""
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set clientName to every text item of (name of (info for jobFolder))
set jobNumber to first item of result
set clientName to (items 2 through -1 of clientName) as string
set AppleScript's text item delimiters to ASTID
set webFolder to ((jobFolder as string) & "Processed:Web_Proofs") as alias
(* INSERT RENAMING HERE - For each image in the folder webFolder I need to perform the renaming mentioned above *)
-- The next section renames the folder for uploading
try
set webFolder to ((jobFolder as string) & "Processed:Web_Proofs") as alias
tell application "Finder" to set name of result to ("Job_" & jobNumber)
on error
set webFolder to ((jobFolder as string) & "Processed:Job_" & jobNumber) as alias
end try
This is a little beyond me. Can anyone help?
Thanks,
Mark
Model: G5 2.0gHz DualCore Power PC
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
tell application "Finder"
repeat with i in (get files of folder ((choose folder) as string) whose name contains "_tn")
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "_tn"}
set textitems to text items of (get name of i)
set AppleScript's text item delimiters to TID
set name of contents of i to "tn_" & items of textitems as Unicode text
end repeat
end tell
That works great but there is a space before the extension so the file name ends up as “tn_image_001 .jpg”
Is it a stray text item delimiter or something?
Awesome! That got it. So is there a problem in the first part of the script where I set the text item delimiter to a space? I set it back to it’s original state.
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set clientName to every text item of (name of (info for jobFolder))
set jobNumber to first item of result
set clientName to (items 2 through -1 of clientName) as string
set AppleScript's text item delimiters to ASTID
If I put return AppleScript’s text item delimiters after that last line it returns {“”}
The problem is, if you change the delimiter and get an error before you change it back,
then the (wrong) value remain persistent for this script until Script Editor (or Script Debugger) quits