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



Reply
 
Thread Tools Rate Thread Display Modes
Old 04-06-2012, 02:04 AM   #1
neilmunn
Guest
 
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
fracai
MVP
 
Join Date: May 2004
Posts: 2,084
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
Renamer
Name Mangler
fracai is offline   Reply With Quote
Old 04-06-2012, 12:16 PM   #3
macosnoob
MVP
 
Join Date: Jan 2007
Posts: 1,872
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:	130
Size:	69.9 KB
ID:	4498  
macosnoob is offline   Reply With Quote
Old 04-06-2012, 03:13 PM   #4
fracai
MVP
 
Join Date: May 2004
Posts: 2,084
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
Red_Menace
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
nbevan
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
Reply

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 09:44 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.