Re: change from upper to lower case
Re: change from upper to lower case
- Subject: Re: change from upper to lower case
- From: Graff <email@hidden>
- Date: Fri, 19 Dec 2003 15:12:33 -0500
Here's the same thing done using Apple's example "essential
sub-routine":
<
http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.07.htm>
You will need to add an option-return character to the end of one line,
it is marked. The mailing list program mucks those characters up.
---------
set lowercaseFolder to (choose folder with prompt "Select the folder to
lowercase files")
if lowercaseFolder is not "" then
tell application "Finder"
set filesToRename to every file in folder lowercaseFolder
repeat with aFile in filesToRename
set theName to my change_case(name of aFile)
set name of aFile to theName
end repeat
end tell
end if
on change_case(this_text)
set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set the source_string to "abcdefghijklmnopqrstuvwxyz"
set the new_text to ""
repeat with this_char in this_text
set x to the offset of this_char in the comparison_string
if x is not 0 then
set the new_text to -- put option-return character here
-- make sure to add the option-return to the end of the previous line!
(the new_text & character x of the source_string) as string
else
set the new_text to (the new_text & this_char) as string
end if
end repeat
return the new_text
end change_case
---------
- Ken
On Dec 19, 2003, at 11:26 AM, Michael Schmidt wrote:
Hi,
Does anyone know of a script to change a folder of 400 files from
upper case to lower case, for example
H001H44 to h001h44
C251C56 to c251c56
etc., etc.,
Hi!
First shot, works with 7-bit-ASCII-Names:
on run
set lowercaseFolder to (choose folder with prompt "Select the folder
to lowercase files")
if lowercaseFolder - "" then
tell application "Finder"
set filesToRename to every file in folder lowercaseFolder
repeat with aFile in filesToRename
set name of aFile to my lowercase(name of aFile)
end repeat
end tell
end if
end run
on lowercase(aText)
set retourStr to ""
repeat with aChar in text items of aText
set thisAsciiNo to ASCII number of aChar
if thisAsciiNo is less than 91 and thisAsciiNo is greater than 64
then
set retourStr to retourStr & (ASCII character (thisAsciiNo + 32))
else
set retourStr to retourStr & aChar
end if
end repeat
return retourStr
end lowercase
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.