Automator Rename Finder Items NOT working in Leopard
Anyone else have this problem, or better yet success?
Macbook Pro, Mac OS X (10.5)
Apple Event: May 7th at 7 am PT
Macbook Pro, Mac OS X (10.5)
Your problem, hardware or software, may not be exactly the same as that of the original poster of this older thread, and it can be very confusing for everybody if we try to answer more than one question in each thread, which can also result in you applying the wrong advice to your particular problem.
In order for us to give your problem our proper attention to try to solve it, would you kindly start your own thread, describing the trouble you are having in the fullest detail, including completing your details to show what Mac or iDevice you are using, what operating system, and what version of the application in question. Please remember to post in the forum relevant to your hardware or version of OS X. A full list of all the support forums is here:
try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
repeat
display dialog "Find and Replace:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result
if the search_string is not "" then exit repeat
end repeat
repeat
display dialog "Replace With:" default answer "" buttons {"Cancel", "OK"} default button 2
set the replacement_string to the text returned of the result
if the replacement_string contains ":" then
beep
display dialog "A file or folder name cannot contain a colon (:)." buttons {"Cancel", "OK"} >default button 2
else if the replacement_string contains "/" then
beep
display dialog "A file or folder name cannot contain a forward slash (/)." buttons {"Cancel", >"OK"} default button 2
else
exit repeat
end if
end repeat
set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set this_item to item i of the item_list
set this_item to (source_folder & this_item) as alias
set this_info to info for this_item
set the current_name to the name of this_info
set change_flag to false
if the current_name contains the search_string then
if the folder of this_info is false then
set the change_flag to true
end if
if the change_flag is true then
-- replace target string using delimiters
set AppleScript's text item delimiters to the search_string
set the text itemlist to every text item of the current_name
set AppleScript's text item delimiters to the replacement_string
set the new itemname to the text itemlist as string
set AppleScript's text item delimiters to ""
my set item_name(thisitem, new itemname)
end if
end if
end repeat
beep 2
on set item_name(thisitem, new itemname)
tell application "Finder"
--activate
set the parent containerpath to (the container of this_item) as text
if not (exists item (the parent containerpath & new itemname)) then
try
set the name of this_item to new itemname
on error the error_message number the error_number
if the error_number is -59 then
set the error_message to "This name contains improper characters, such as >a colon (:)."
else --the suggested name is too long
set the error_message to error_message -- "The name is more than 31 >characters long."
end if
--beep
tell me to display dialog the error_message default answer new itemname >buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {new itemname, button_pressed}
if the button_pressed is "Skip" then return 0
my set item_name(thisitem, new itemname)
end try
else --the name already exists
--beep
tell me to display dialog "This name is already taken, please rename." default answer >new itemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {new itemname, button_pressed}
if the button_pressed is "Skip" then return 0
my set item_name(thisitem, new itemname)
end if
end tell
end set itemname
Automator Rename Finder Items NOT working in Leopard