Handler works only once
Handler works only once
- Subject: Handler works only once
- From: Rich Carroll <email@hidden>
- Date: Wed, 19 Feb 2003 18:16:59 -0600
Hello all,
I seem to be having a problem with a handler working only the first time
thru. If I call it again, I get "Finder got an error: Can't continue
wrangleName" (handler name) error.
I've tried calling the handler for other handlers, as well as from itself.
Properties seem to be in the same form both times. I've also tried both
Apple's script editor as well as Script Debugger. Both return same result.
The purpose of the script is to rename files and folders using only
alphanumeric characters. I wanted to put in a log as well, but I'm stuck on
this useless error message.
Any ideas?
Rich Carroll
email@hidden
global folderName
global goodText
global reWrite
global folderPath
global newFileName
on run
set folderPath to choose folder with prompt "Select folder to be
checked."
set goodText to "65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 95; 97; 98; 99; 100; 101;
102; 103; 104; 105; 106; 107; 108; 109; 110; 111; 112; 113; 114; 115; 116;
117; 118; 119; 120; 121; 122; 49; 50; 51; 52; 53; 54; 55; 56; 57; 48"
set reWrite to false
set AppleScript's text item delimiters to ":"
set folderPath to folderPath as string
set folderName to text item -2 of folderPath as string
wrangleName(folderName, folderPath)
end run
on wrangleName(folderName, folderPath)
set newFileName to ""
set goodText to "65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 95; 97; 98; 99; 100; 101;
102; 103; 104; 105; 106; 107; 108; 109; 110; 111; 112; 113; 114; 115; 116;
117; 118; 119; 120; 121; 122; 49; 50; 51; 52; 53; 54; 55; 56; 57; 48"
set reWrite to false
repeat with i in folderName
if goodText contains (ASCII number of i) then
set newFileName to (newFileName & i) as string
else if (ASCII number of i) = 46 then
set extension to true
set newFileName to (newFileName & i) as string
else
set reWrite to true
end if
end repeat
set newFileName to every text item in newFileName as string
changeName(folderPath)
return {newFileName, reWrite}
end wrangleName
on changeName(folderPath)
tell application "Finder"
set folderItems to list folder folderPath without invisibles
repeat with i in folderItems
set a to (folderPath & i) as alias
get properties of a
set myClass to class of result
if myClass = folder then
set properties of folder folderPath to {name:newFileName}
set folderName to i as string
set folderPath to a as string
wrangleName(folderName, folderPath)
else if myClass = document file then
set properties of file folderPath to {name:newFileName}
end if
end repeat
end tell
end changeName
--
Richard McCormick-Carroll
Application Specialist
Capps Digital Development Group
email@hidden
email@hidden
312.220.1679 @ Desk
312.520.1679 @ Cell
www.cappsdigital.com
_______________________________________________
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.