Go Back   The macosxhints Forums > OS X Help Requests > AppleScript

Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 04-06-2012, 02:04 AM   #1
Posts: n/a
Red face Crop filenames after certain character?

I have a folder containing about 5000 files with names like:

Invoice 10.1 (2012) (Digital) (4-Attachments).pdf
Carbon_Copy_-_Invoice_No_02_(2010)_(2 Copies)_(Filed).pdf
01.Reciept #04 (Scanned-Copy).doc

I want to rename these files by removing everything from the first bracket onwards, so they look like this:

Invoice 10.1.pdf
Carbon Copy - Invoice No 02.pdf
01.Reciept #04.doc

Automator has replaced the _ for me, but I can't seem to get any further.
  Reply With Quote
Old 04-06-2012, 11:13 AM   #2
Join Date: May 2004
Posts: 2,094
I'm not sure that Automator can do this without jumping out to AppleScript, and I'll let someone else tackle that.

There are also several alternatives.
Command Line
Name Mangler
fracai is offline   Reply With Quote
Old 04-06-2012, 12:16 PM   #3
Join Date: Jan 2007
Posts: 1,906
If by "bracket" you mean "(", Red Menace, a frequent contributor to the Apple forums, has an Automator action for you: Change Name of Finder Items, http://homepage.mac.com/red_menace/S...automator.html. Below you'll see the settings that worked on your three-file sample.
Attached Thumbnails
Click image for larger version

Name:	ch.jpg
Views:	140
Size:	69.9 KB
ID:	4498  
macosnoob is offline   Reply With Quote
Old 04-06-2012, 03:13 PM   #4
Join Date: May 2004
Posts: 2,094
That's nifty, I didn't realize Automator was that intelligent. Does it support full regex renaming?
fracai is offline   Reply With Quote
Old 04-06-2012, 04:30 PM   #5
All Star
Join Date: Mar 2006
Location: Littleton, Colorado, USA
Posts: 515
"Automator" and "intelligent" aren't terms that are normally seen together. Automator started out as a good idea, but Apple really hasn't put much effort into it, so getting workflows to work in some cases can be aggravating.

There are a few actions out there that use regular expressions (for example from BBEdit), it just depends on the purpose of the action. My Change Name of Finder Items action is basically a wrapper around an AppleScript, something that Automator is good at. It is still a bit quirky in that the Automator text fields strip off any leading and trailing whitespace, but it was written to strip characters from a file name by character(s) or index.
MacBook Pro / OS X Mavericks (10.9.3) / Xcode 5.1.1 / RubyMotion FTW
Red_Menace is offline   Reply With Quote
Old 11-26-2012, 01:26 AM   #6
Registered User
Join Date: Nov 2012
Posts: 1
Is the Automator action for: Change Name of Finder Items still available for download from anywhere?
nbevan is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 05:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.