Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Need to remove characters from middle of file name with automator

Hello,


I have searched high and low for a solution and can not find a solution for my problem and I am sure it can be done but I don't have the skills with this to get it done. I have over 3000 files that I need the middle portion removed. My file name consists of the following, 000000_items-to-be-moved_00.ext, I would require the area between the two underscores to be removed and replaced with a underscore. Is there any one that can help me with a script or a way I can get this done with Automator.

Automator-OTHER, Mac OS X (10.6.8)

Posted on Jun 2, 2015 7:46 AM

Reply
Question marked as Best reply

Posted on Jun 2, 2015 8:11 AM

Try using this AppleScript:


tell application "Finder"

repeat with this_file in (get items of (choose folder)) --do not change this line

set the_name to name of this_file

set name_1 to items 1 thru (offset of "_" in the_name) of the_name as string

set name_2 to items ((offset of "_" in the_name) + 1) thru -1 of the_name as string

set name_3 to items ((offset of "_" in name_2) + 1) thru -1 of name_2 as string

set name of this_file to name_1 & name_3

end repeat

end tell


(128204)

2 replies
Question marked as Best reply

Jun 2, 2015 8:11 AM in response to PhilCall

Try using this AppleScript:


tell application "Finder"

repeat with this_file in (get items of (choose folder)) --do not change this line

set the_name to name of this_file

set name_1 to items 1 thru (offset of "_" in the_name) of the_name as string

set name_2 to items ((offset of "_" in the_name) + 1) thru -1 of the_name as string

set name_3 to items ((offset of "_" in name_2) + 1) thru -1 of name_2 as string

set name of this_file to name_1 & name_3

end repeat

end tell


(128204)

Need to remove characters from middle of file name with automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.