• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: change case script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: change case script


  • Subject: RE: change case script
  • From: Laine Lee <email@hidden>
  • Date: Fri, 02 Nov 2001 12:10:51 -0600

On 11/2/01 6:47 AM, "jake williamson 28" <email@hidden>
wrote:

> 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??
>

Here's one you can use if you have Akua Sweets 1.4.3. It walks folders so
you can use it on a hierarchy. It only changes text files, but you can
modify that. Save it as an applet and give it plenty of memory, then drop
your root folder on it.

-----------

-- Properties
property kasPrefName : "LowerCaser"
property kasExtToDo : ""
property kasTypesToDo : "TEXT"

-- Globals
global gasInfoWind -- Info window
global gasInfoPos -- Position of info window
global gasFoldersToDo -- The folders left to process
global gasConverted -- Number gone!
global gasChecked -- Number checked!
global gasPrefix -- Adjusted kasPrefix (munge the % parms)


on open fsObjs
-- Load prefs, show window
pfLoad()


set gasConverted to 0
set gasChecked to 0

set gasInfoWind to display info kasPrefName ,
located at gasInfoPos ,
message "Scanning
"


-- Do files
set gasFoldersToDo to {}

repeat with fsObj in fsObjs
set myInfo to (basic info for fsObj)

if (file type of myInfo is "fold") then
set gasFoldersToDo to gasFoldersToDo & {fsObj}
else
DoOne(fsObj)
end if
end repeat

-- Do folders
repeat while gasFoldersToDo is not {}
-- Pop one off the end
set n to the number of items of gasFoldersToDo
set fsObj to item n of gasFoldersToDo

if (n > 1) then
set gasFoldersToDo to items 1 through (n - 1) ,
of gasFoldersToDo
else
set gasFoldersToDo to {}
end if

display info gasInfoWind located at (15 * 32) ,
message ("Folders to go: " & n) ,
at line 6


-- Process it
GoDeep(fsObj)
end repeat

display info gasInfoWind message "DONE!"

pause for 5 with seconds timing -- Let screen wait...

set gasInfoPos to screen location of ,
(display info gasInfoWind with disposal)

pfSave() -- Save window location
end open


on DoOne(fsObj)
set fname to name of (basic info for fsObj)

set gasChecked to gasChecked + 1
display info gasInfoWind ,
message ("Checked: " & gasChecked) ,
at line 4

set gasSearch to " "
set gasReplace to "_"
----------
set newName to munge fname ,
from gasSearch ,
to gasReplace
set flow to transcribe fname as lower cased
if (newName is not fname) then
display info gasInfoWind at line 4 ,
message "Renaming" & tab & fname

try
collate fsObj by renaming it to newName
on error errStr number errNum
display info gasInfoWind at line 15 ,
message "Error" & tab & errStr & tab & errNum
end try
set gasConverted to gasConverted + 1
-----------
-- Rename to lowercase?

considering case
if flow is not fname then
collate fsObj by renaming it to flow
display info gasInfoWind ,
message ("Changed: " & gasConverted) ,
at line 5
end if
end considering
else
considering case
if flow is not fname then
collate fsObj by renaming it to flow
display info gasInfoWind ,
message ("Changed: " & gasConverted) ,
at line 5
set gasConverted to gasConverted + 1
end if
end considering
end if
end DoOne


on GoDeep(foldObj)
display info gasInfoWind ,
message "Path: " & (foldObj as string)

set daddy to foldObj as string

-- Do kinds that match
display info gasInfoWind ,
message "Scanning files" at line 5

if (kasExtToDo is "") then
set myItems to the entries in foldObj ,
whose types are in kasTypesToDo
else
set myItems to the entries in foldObj ,
whose types are in kasTypesToDo ,
whose names match kasExtToDo
end if

repeat with myItem in myItems
DoOne((daddy & myItem) as alias)
end repeat

-- Do folders
display info gasInfoWind ,
message "Scanning subfolders" at line 5

set myItems to the entries in foldObj ,
whose kinds are a folder

repeat with myItem in myItems
set gasFoldersToDo to gasFoldersToDo & {(daddy & myItem) as alias}
end repeat

-- Done
display info gasInfoWind ,
message "
" at line 5
end GoDeep


on pfLoad()
try
set ourPrefs to (the preference named kasPrefName)
set gasInfoPos to item 1 of ourPrefs
on error
set gasInfoPos to {0, 0}
end try
end pfLoad


on pfSave()
save preference {gasInfoPos} named kasPrefName
end pfSave
-------------
--
Laine Lee
email@hidden
http://www.txdirect.net/users/llee

------ End of Forwarded Message


  • Prev by Date: Re: Why o why won't my script/app open? - solved (it's sneaky)
  • Next by Date: Re: a few questions
  • Previous by thread: Re: change case script
  • Next by thread: Re: change case script
  • Index(es):
    • Date
    • Thread