Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LordMelkor

macrumors newbie
Original poster
Aug 6, 2008
29
0
Often times I download files where the spaces are replaced by underscores, so I made a workflow in automator that replaces all the _'s with spaces. But in addition to the _'s, files often have tags which I wish to remove, such as the crc32 within brackets. However, the Automator replacement, doesnt seem to allow any wildcard type replacements (ie. remove all stuff within brackets). How can I implement this into my Automator workflow (like could I add a bash or applescript component after the text replacement to do this?)

Thanks!

P.S. And I'm looking specifically at an automator workflow solution, because of the convenience of being able to run it from the right-click menu.


Example:
Original Filename -
[blah]_abcde_fghi_[11CB25F].txt

Want -
abcde fghi.txt
 

tedsmith3rd

macrumors member
Aug 30, 2006
54
0
US
Thanks! That works. But what would I have to include to include to remove the preceding and trailing _'s (sorry I'm not familiar with perl syntax :eek:)

Try just adding another regex file renamer to your workflow after the one above and have it change "_" to a space.
 

LordMelkor

macrumors newbie
Original poster
Aug 6, 2008
29
0
If I do that, ill have a leading and trailing Space instead of a leading and trailing _ either way, if that's the case I cant sort the files properly by name since the first letter is preceded by a space.
 

tedsmith3rd

macrumors member
Aug 30, 2006
54
0
US
Try adding another with ^\s*(.+?)\s*$ to $1 (or \\1)
If that doesn't do it then try these instead: ^\s* to blank and \s*$ to blank

Still no joy? Start over and change _ to space first, then change \s*\[.+?\]\s* to blank.
 

LordMelkor

macrumors newbie
Original poster
Aug 6, 2008
29
0
Try adding another with ^\s*(.+?)\s*$ to $1 (or \\1)
If that doesn't do it then try these instead: ^\s* to blank and \s*$ to blank

This doesn't seem to do anything... :confused:

Still no joy? Start over and change _ to space first, then change \s*\[.+?\]\s* to blank.

So close but not quite :( it removes everything correctly but I lose the spaces in the file name itself!!

i.e.
Input: [WOWEE]_saywot_wazzup_[butterblarg].txt
Output: saywotwazzup.txt
Desired: saywot wazzup.txt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.