Re: change case script
Re: change case script
- Subject: Re: change case script
- From: "Marc K. Myers" <email@hidden>
- Date: Fri, 02 Nov 2001 12:53:03 -0500
- Organization: [very little]
>
Date: Fri, 02 Nov 2001 12:47:40 +0000
>
Subject: change case script
>
From: jake williamson 28 <email@hidden>
>
To: <email@hidden>
>
>
hello!!
>
>
is it possible to compile a script that takes all the file names in a folder
>
and coverts them to lower case and replaces a space with an underscore??
>
>
for example:
>
>
Wild About Elephants.jpg
>
>
would become
>
>
wild_about_elephants.jpg
>
>
we get a lot of pc cd's with images and although i can copy them across the
>
network (which preserves the file name) pc nameing conventions seem to be in
>
title case.
>
>
can this be done???
Here's a very fast handler that converts any set of characters to another:
property oldChars : {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", [optn-L]
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", [optn-L]
"U", "V", "W", "X", "Y", "Z", " "}
property newChars : {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", [optn-L]
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", [optn-L]
"u", "v", "w", "x", "y", "z", "_"}
set theFile to (choose file)
set theName to chgCase(name of (info for theFile))
tell application "Finder" to set the name of theFile to theName
on chgCase(theText)
set od to AppleScript's text item delimiters
repeat with i from 1 to 27
set AppleScript's text item delimiters to (item i of oldChars)
set theText to text items of theText
set AppleScript's text item delimiters to (item i of newChars)
set theText to (theText as text)
end repeat
set AppleScript's text item delimiters to od
return theText
end chgCase
Please note that "[optn-L]" stands in for the actual AppleScript
continuation character.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[11/2/01 12:50:40 PM]