Maybe this is close to what you need (untested). I advise you to duplicate some files to test the script.
set target_fol to (choose folder with prompt "Choose a folder whose files need to be renamed.")
tell application "Finder"
set items_ to files of target_fol
repeat with item_ in items_
try
set new_name_ to name of item_
set name of item_ to ((text 1 thru 7 of name_) & (text -8 thru end of name_))
on error e
display dialog e buttons {"OK"} default button 1
end try
end repeat
end tell
set target_fol to (choose folder with prompt "Choose a folder whose files need to be renamed.")
tell application "Finder"
set items_ to files of target_fol
repeat with item_ in items_
try
set name_ to name of item_
set name of item_ to ((text 1 thru 7 of name_) & (text -8 thru end of name_))
on error e
display dialog e buttons {"OK"} default button 1
end try
end repeat
end tell
if you want to take it all the way for me,
how can i make this script so i can attatch it to a folder and it run automatically on whatever file is added to the folder.
thanx again for the quick response and solution.
excellent, jmarsh
This will work only on files (not folders) that arrive in the attached folder. If you run into cases where it fails, come back and we’ll try to fix it.
on adding folder items to this_folder after receiving added_items
repeat with item_ in added_items
if (folder of (info for item_)) is false then
tell application "Finder"
try
set name_ to name of item_
set name of item_ to ((text 1 thru 7 of name_) & (text -8 thru end of name_))
end try
end tell
end if
end repeat
end adding folder items to