Old Photoshop and Illustrator files with garbled file names to update

At one time, a user thought file names like “03R30425I.ART/PHOTO” were acceptable. Now, I have thousands of these garbled file names that need updating. The down side is that some are Illustrator files that need to be updated in Illustrator and some are Photoshop files that need to updated as TIFs. I am planning a basic structure, but not sure if it is the most efficient for this many files.

Script outline:
Probably needs to process an entire folder, looking for Photoshop and Illustrator files, saving them as updated files in their respective apps.
Old file names need to have the garbage after the dot removed and saved with modern naming convention.

A list of the unusual suspects:
.Art(with or without /anything) = .eps
.AA = .eps (sometimes _1.eps, probably no easy fix, .eps will be primary)
.AB = _2.eps
.AC = _3.eps
.AD = _4,eps
.Art1 = _A.eps
.Art2 = _B.eps
.Art3 = _C.eps
.Art4 = _D.eps
.A1 = _A.eps
.A2 = _B.eps
.A3 = _C.eps
.A4 = _D.eps

Am I going in the right direction for this? Any suggestions to improve speed?

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)

Here’s a bit more…

Previous attempts generated file names like “03R30425I.ART.eps” and “03R30425IAA.ART” where the .ART. and AA. before the dot need to be removed.

I do have one basic script that I picked up to do the simple change extension function, but it does not modify the files’ contents. Also, I have noticed that simply changing the extension on old Photoshop files actually modifies the contents, like odd resolution and dimension changes. So, the workflow should include actually opening and ‘save as’ to incorporate the name change.

set thePath to choose folder with prompt "Select folder to rename files in:"
set ext to text returned of (display dialog "Extension to Replace:" default answer "")
set extNew to text returned of (display dialog "Replace With:" default answer "")

tell application "Finder"
	try
		set the datlist to files of thePath whose name extension is ext
	end try
	repeat with dat in datlist
		set ext_length to count (get name extension of dat)
		try
			set name of dat to ((text 1 thru -(ext_length + 1) of (get name of dat)) & extNew)
		on error e
			display dialog e
		end try
	end repeat
end tell

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)

Another reply to my own thread… :confused:

Here’s a start to what I think could become a working script, but is taking time for me to sort out what to do first.

Here’s a list of the sort of file names I am up against:

  1. 03R20409N.ART
  2. 03R20409N.ART/PHOTO
  3. 03R20409N.ART/PTS
  4. 03R20409N.ART.eps
  5. 03R20409N.AA
  6. 03R20409N.AB
  7. 03R20409N.AC
  8. 03R20409N.AD
  9. 03R20409N.A1
  10. 03R20409N.A2
  11. 03R20409N.A3
  12. 03R20409N.A4
  13. 03R20409N.Art1
  14. 03R20409N.Art4
  15. 03R20409N.Art4
  16. 03R20409N.Art4

Here is what those should look like:

  1. 03R20409N.eps
  2. 03R20409N.tif
  3. 03R20409N.tif
  4. 03R20409N.eps
  5. 03R20409N_1.eps
  6. 03R20409N_2.eps
  7. 03R20409N_3.eps
  8. 03R20409N_4.eps
  9. 03R20409N_A.eps
  10. 03R20409N_B.eps
  11. 03R20409N_C.eps
  12. 03R20409N_D.eps
  13. 03R20409N_A.eps
  14. 03R20409N_B.eps
  15. 03R20409N_C.eps
  16. 03R20409N_D.eps

Its starting to look more and more daunting with the more incoming requirements of the script. :frowning:

I think I need the long weekend coming up!

set inputFolder to choose folder with prompt "Choose an input folder."
set folderName to name of (info for inputFolder)

tell application "Finder" to set pshopFiles to files of folder inputFolder whose name extension is in {"tif", "tiff", "ART1", "ART2", "ART3", "ART4", "ART/PTS"} or kind is in {"Photoshop", "Adobe Photoshop EPS file"}

tell application "Finder" to set IllFiles to files of folder inputFolder whose name extension is in {"ART", "ART1", "ART2", "ART3", "ART4"} or kind is in {"Adobe Illustrator", "Illustrator", "Adobe Illustrator 9"}

repeat with oneFile in pshopFiles
	tell application "Adobe Photoshop CS3"
		activate
		--open oneFile
		set ix to 0
		set ix to ix + 1
		set Ext to name extension of oneFile
		set newName to ix as text
		set name of contents of oneFile to newName & "." & Ext
		--modify in Photoshop CS3 and change file name in inputFolder as a TIF file. Replace the original oneFile or delete it.
	end tell
end repeat

repeat with oneFile in IllFiles
	tell application "Adobe Illustrator"
		activate
		set user interaction level to never interact
		open oneFile with options {update legacy text:true} without dialogs
		set ix to 0
		set ix to ix + 1
		set Ext to name extension of oneFile
		set newName to ix as text
		set name of contents of oneFile to newName & "." & Ext
		--modify in Photoshop CS3 and change file name in inputFolder as an EPS. Either replace oneFile or delete it.
	end tell
end repeat

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)

Hi

if i where change the name extension i would go for something like this but it is just personal choice!

tell application "Finder"
	set t to every file of (choose folder)
	repeat with i in t
		if name of i ends with ".ART.eps" then
			set creator type of i to "ART5"
			set thename to name of i
			set theext to ".ART.eps"
			set OldDelims to AppleScript's text item delimiters
			set AppleScript's text item delimiters to theext
			set newText to text items of thename
			set AppleScript's text item delimiters to ".eps"
			set newText to newText as text
			set AppleScript's text item delimiters to OldDelims
			set name of i to newText
		end if
	end repeat
end tell

i added the bit about creator type to see if this would be easier for you instead of actually opening the file in its native application just to save back down again.
we get a lot of files in that don’t know who the belong to so i use a small script to change the creator type and everything seems to be okay!!

just a thought,!!
the thing with having so many differently named files means your script will never be very small or compact.

good luck

Thanks Pidge! This never seems to be as simple as I hope, but this script will be valuable to a few different groups in other divisions of my organization. I’ll keep the thread updated as I go, probably just as I have free time.

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)

Here is a better outline of what I am doing with the script. This one seems to be going slow as I have too many other projects and tasks currently…


on fileName() --This part will expand greatly to cover as many of the variables in the old file names and change them to the current naming conventions. All the work for turning the original filename into the new filename will be done here. Get the filename of oneFile and update.
	tell application "Finder"
		set t to every file of (choose folder)
		repeat with i in t
			if name of i ends with ".ART.eps" then
				set creator type of i to "ART5"
				set thename to name of i
				set theext to ".ART.eps"
				set OldDelims to AppleScript's text item delimiters
				set AppleScript's text item delimiters to theext
				set newText to text items of thename
				set AppleScript's text item delimiters to ".eps"
				set newText to newText as text
				set AppleScript's text item delimiters to OldDelims
				set name of i to newText
			end if
		end repeat
	end tell
end fileName

set inputFolder to choose folder with prompt "Choose an input folder."
set folderName to name of (info for inputFolder)

tell application "Finder" to set pshopFiles to files of folder inputFolder whose name extension is in {"tif", "tiff", "ART/PTS"} or kind is in {"Photoshop", "Adobe Photoshop EPS file"}

tell application "Finder" to set IllFiles to files of folder inputFolder whose name extension is in {"eps", "ai", "ART", "ART1", "ART2", "ART3", "ART4"} or kind is in {"Adobe Illustrator", "Illustrator", "Adobe Illustrator 9"}

repeat with oneFile in pshopFiles
	tell application "Adobe Photoshop CS3"
		activate
		open file oneFile
		--modify in Photoshop CS3 and change file name in inputFolder as a TIF file. Replace the original oneFile or delete it.
		fileName()
		--save as TIF to inputFolder turning old name of oneFile into the new name
	end tell
end repeat

repeat with oneFile in IllFiles
	tell application "Adobe Illustrator"
		activate
		set user interaction level to never interact
		open oneFile with options {update legacy text:true} without dialogs
		--modify in Photoshop CS3 and change file name in inputFolder as an EPS. Either replace oneFile or delete it.
		my fileName()
		--save as EPS to inputFolder turning old name of oneFile into the new name
	end tell
end repeat

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger4
Browser: Firefox 3.0
Operating System: Mac OS X (10.4)