tell application "Finder"
set displaydialog to display dialog "Enter volume number, delimiter separated by a comma" default answer ""
set thedelimiters0 to the text returned of displaydialog
set AppleScript's text item delimiters to ","
set thevolume to first text item of thedelimiters0
set thedelimiters to second text item of thedelimiters0
set AppleScript's text item delimiters to ""
repeat with aitem in (get selection)
set x to name of aitem
set theext to name extension of aitem
set AppleScript's text item delimiters to thedelimiters
set z to second text item of x
set z1 to text 1 thru 2 of z
set z2 to thevolume & "x" & z1 & "." & theext
set theconfirm to display dialog "Accept new name: " & z2 buttons {"ok", "cancel"} default button "ok"
if button returned of theconfirm is "ok" then
set name of aitem to z2
else
display dialog "bye!"
end if
end repeat
end tell
This script works on Finder files which are named like
(volume number: 2, delimiter: 2VL)
Tax notes.2VL03 - Part1.doc --result: 2x03.doc
Tax notes.2VL04 - Part1.doc --result: 2x04.doc
Tax notes.2VL05 - Part1.doc --result: 2x05.doc
Tax notes.2VL06 - Part1.doc --result: 2x06.doc
(volume number: 1, delimiter: 1x)
MICS lecture - 1x04 - Part1.rtf --result: 1x04.rtf
MICS lecture - 1x05 - Part1.rtf --result: 1x05.rtf
MICS lecture - 1x06- Part1.rtf --result: 1x06.rtf
(volume number: 3 delimiter: 3VLS)
History.3VLS04 - Part1.doc --result: 3x04.doc
Problems with this script:
- When cancel is clicked, the display dialog “bye!” does not appear.
- It does not work properly on multiple files if “cancel” is clicked for any one file.
- When the dialog box for “ok”, “cancel” appears, it is frontmost but it still does not accept the return key. The “Finder” in the “Finder” menu bar (near the apple logo in the menu bar) is pressed when the return key is pressed.