--on set_item_name(this_item, new_item_name)
set this_item to "Macintosh HD:Users:RLP:Desktop:work folder:amer.weihnachten1.jpg"
set new_item_name to "amer.weihnachten1.jpg"
tell application "Finder"
set the parent_container_path to (container of this_item)
try
set the name of this_item to new_item_name
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_item_name buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {new_item_name, button_pressed}
if the button_pressed is "Skip" then return 0
my set_item_name(this_item, new_item_name)
end try
end tell
--end set_item_name
On Mar 26, 2010, at 10:05 AM, Yvan KOENIG wrote:
Le 26 mars 2010 à 16:49,
email@hidden a écrit :
You could insert this into your script:
tell application "Finder"
set theKind to class of item (currentItem as text)
if theKind is folder then set theKind to "folder"
end tell
In place of:
set theKind to kind of currentItem
Yours and mine return "folder" it the treated item is a folder.
Also, I'd still caution against using index as a variable, it is an appleScript keyword. In general, if your compiler colors a variable differently than the other variables in your script, you should pick a different name for the variable.
I definitively agree.
This is why, to be free of this kind of problem, I use French_like names for the variables in my own scripts.
Yvan KOENIG (VALLAURIS, France) vendredi 26 mars 2010 17:01:36
Robert Poland - Fort Collins, CO