Hey, so I’ve got the following script:
tell application "Finder" to set ItemList to selection
repeat with thisItem in ItemList
tell application "Finder"
set diag_1 to display dialog "Please Add Version Comments:
(Automatically Replaces)" default answer "" buttons {"Add", "Cancel", "Replace"} default button 3 with title "Add Keywords"
set a_com to text returned of result
end tell
-- automatic appends comment; replace on command v1.5
set {name:Old_Name, name extension:Ext} to info for thisItem as alias
if Ext is missing value then set Ext to ""
if Ext is not "" then set Old_Name to text 1 thru ((count Old_Name) - (count Ext) - 1) of Old_Name
tell Old_Name to set {suffixText, suffixNumber} to {text -3 thru -2, text -1}
considering case
set isRevised to suffixText is " r" and suffixNumber is in "123456789"
end considering
if isRevised then
set New_Name to text 1 thru -4 of Old_Name & suffixText & ((suffixNumber as integer) + 1) & "." & Ext
else
set New_Name to Old_Name & " r1." & Ext
end if
tell application "Finder"
set dupItem to duplicate thisItem
set name of dupItem to New_Name
if button returned of diag_1 is "Add" then
set ItemList to selection
if not ItemList is {} then
repeat with thisItem in ItemList
set p_path to (POSIX path of (thisItem as alias))
set e_com to comment of thisItem
if e_com is "" then
set comment of thisItem to a_com
else if button returned of diag_1 is "Replace" then
set n_com to e_com & ", " & a_com
set comment of thisItem to n_com
set n_com2 to e_com & ", " & a_com
end if
end repeat
end if
else
set ItemList to selection
if not ItemList is {} then
repeat with thisItem in ItemList
set comment of thisItem to a_com
end repeat
end if
end if
end tell
end repeat
-- v 1.5
Basically this script prompts you for comments, duplicates the item and adds a revision number to it (“r1”,“r2”,“r3”)
I’ve got two things I haven’t quite been able to hash out”
-
Once we get to “r10”, the next revision is “r10 r1”. How do I get an r11 here?
-
If I try to run this on a folder, i get a folder with a revision number and a trailing “.”
Can anyone help me debug this?
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)