Hi all,
I have been running a script that renames a filename depending on its structure and also changes the filenames to capital letters. While it works most of the time, it seems to be stalling (or something) and its been missing files that are dropped into the folder. I have a 1 minute delay on the folder to make sure all the files are seen by the script but it still seems to be missing some.
So, what I am looking for some help with is - is there some type of loop I can kick in or should I add a check to another folder to check for the capital letters and kick it back to the first folder to start it again if the filename isn’t capitalized (and therefore has not been run through the script)?
Thanks!
Courtney
-------------------------------script below--------------------------------------------------
on adding folder items to thisFolder after receiving theItems
set {ASTIDS, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, “"}
set theItems to (list folder thisFolder without invisibles)
repeat with anItem in theItems
set theName to text 8 thru (length of anItem) of anItem
set itemPath to ((thisFolder as string) & anItem) as alias
set itemParts to every text item of theName as list
set partCount to count itemParts
if partCount = 8 then
set newName to (get item 1 of itemParts) & "”
set newName to newName & (get item 2 of itemParts) & “"
set newName to newName & (get item 3 of itemParts) & "”
set newName to newName & (get item 4 of itemParts) & “"
set newName to newName & (get item 8 of itemParts)
else if partCount = 7 then
set newName to (get item 1 of itemParts) & "”
set newName to newName & (get item 2 of itemParts) & “"
set newName to newName & (get item 3 of itemParts) & "”
set newName to newName & (get item 4 of itemParts) & “"
set newName to newName & (get item 7 of itemParts)
else if partCount = 6 then
set newName to (get item 1 of itemParts) & "”
set newName to newName & (get item 2 of itemParts) & “"
set newName to newName & (get item 3 of itemParts) & "”
set newName to newName & (get item 4 of itemParts) & “_”
set newName to newName & (get item 6 of itemParts)
end if
set newName to changeCaseOf(newName)
tell application “Finder”
set properties of itemPath to {name:newName}
end tell
end repeat
set AppleScript’s text item delimiters to ASTIDS
end adding folder items to
on changeCaseOf(thisText)
set the comparisonString to “abcdefghijklmnopqrstuvwxyz”
set the sourceString to “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
set the newText to “”
repeat with thisChar in thisText
set x to the offset of thisChar in the comparisonString
if x is not 0 then
set the newText to (the newText & character x of the sourceString) as string
else
set the newText to (the newText & thisChar) as string
end if
end repeat
return the newText
end changeCaseOf
Model: G5
Browser: Firefox 3.5.3
Operating System: Mac OS X (10.4)