filename

I am trying a simple applescript to captilize all filenames in a folder. What I have is a folder with lowercase filenames and I want to convert all to uppercase filenames.

tell application “Finder”
set File_Location to ((choose folder with prompt “Select a Folder”) as text)
–here change all files in that folder to ALL CAPS
display dialog “Complete”
end tell

Completely vanilla solution (handled completely by standard addtitions)

property lowerList : "abcdefghijklmnopqrstuvwxyz" --{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
property upperList : {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} --"ABCDEFGHIJKLMNOPQRSTUVWXYZ" --

set File_Location to ((choose folder with prompt "Select a Folder") as text)
--here change all files in that folder to ALL CAPS 
set fileList to list folder File_Location without invisibles
repeat with thisFileName in fileList
	set thisFileName to thisFileName as string
	set charCount to the count of characters in thisFileName
	set newName to ""
	repeat with charNum from 1 to charCount
		set thisChar to character charNum of thisFileName
		try
			set charPos to offset of thisChar in lowerList
			--if it does not error or come back as 0 it was found
			if charPos is not equal to 0 then
				set newName to newName & item charPos of upperList as string
			else
				set newName to newName & thisChar as string
			end if
		on error
			set newName to newName & thisChar as string
		end try
	end repeat
	set thisFilePath to File_Location & thisFileName as string
	set newName to change case of thisFileName to upper
	try --it could fail if there is a folder present
		tell application "Finder" to set the name of file thisFilePath to newName
	on error
	end try
end repeat

display dialog "Complete"

Non-Vanilla solution using click here–>ACME’s change case command<–click here

set File_Location to ((choose folder with prompt "Select a Folder") as text)
--here change all files in that folder to ALL CAPS 
set fileList to list folder File_Location without invisibles
repeat with thisFileName in fileList
	set thisFileName to thisFileName as string
	set thisFilePath to File_Location & thisFileName as string
	set newName to change case of thisFileName to upper
	try --it could fail if there is a folder present
		tell application "Finder" to set the name of file thisFilePath to newName
	on error
	end try
end repeat
display dialog "Complete"

Good luck,

Mytzlscript’s already covered the ground. :slight_smile: Just to point out an alternative to the ACME osax: Satimage. This is available in both OS 9 and OS X versions and has an ‘uppercase’ command.

http://www.satimage.fr/software/en/soft9.html#osax

http://www.satimage.fr/software/en/softx.html#osax[/url]

I don’t know what happened to that second URL. I’ll try posting it again. Wish me luck. :wink:

http://www.satimage.fr/software/en/softx.html#osax

I’ve seen this happen several times over the last few days. I think the server/BBS must hiccup occasionally. :wink:

– Rob

Just had to make a change to this line was getting a syntax error at case and now I am getting an error at upper as varialbe upper is not defined

set newName to changecase of thisFileName to upper

Just had to make a change to this line was getting a syntax error at case and now I am getting an error at upper as varriable upper is not defined. I also tried uppercase still can’t get it to work

set newName to changecase of thisFileName to upper

to use this solution you must:

  1. Have Acme Script Widget’s installed to use the “change case” command. Otherwise you will get a synax error. Also, if it is telling you the variable “upper” is not defined, then you definitely don’t have Acme Script Widget loaded because it is part of Acme’s dictionary. If you do have it loaded then…

  2. Use the correct command “change case” not “changecase”

The vanilla solution should also work. That one does not require 3rd party osax.

Good luck.

Where do I find Acme Script Widget’s. Or where can I get Acme Script Widget’s

Hi,

In my original post I provided a link to where you could get it. Sorry, sometimes they are hard to see. Just roll your mouse over where it says Acme’s Change Case Command.

If it does not work for you go here:
http://osaxen.com/acme_script_widgets.html

Or if you don’t want to use ACME the vanilla solution is free.

Best,