Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get bunches of files I need to rename. The original filenames normally have 7 digits - plus an optional character (or two), followed by a space then a whole string of other characters. I need to rename them to be such that the space and everything after it is replaced by '-z'.

For example: (original filenames)

3543679 ggry Hugh highs Bhutto.jpg

6789456 hfghh hfghh death.eps

8753674a hfryg gyjbff hfghh.png

4686536c Guggenheim.jpg

Would become: (renamed filenames) 3543679-z.jpg




Anyone got any ideas how to automate this?

share|improve this question
I like Lauri's answer below, but personally I would use Name Mangler I think it is easily worth the $10 especially when you take into account the free support that is offered on their mailing list. – Dave Nelson Nov 16 '12 at 14:11

Try running something like this in Terminal:

cd ~/Some\ folder
for f in *; do mv "$f" "${f/ *./-z.}"; done
share|improve this answer
Am I missing something? I am not real strong at CLI stuff - all I managed to do was end up with a single file called -z.jpg! – Mark Nov 17 '12 at 10:33
It works for me with the examples in the question. Do the filenames start with spaces or something? – user495470 Nov 17 '12 at 11:34
Hey Lauri, sorry - forgot to thank you. Thanks! Do I cd into the folder contains the files? Then type in the rest? I'll try again tomorrow, it's getting late. – Mark Nov 17 '12 at 13:55
Thanks Lauri, I get it now. – Mark Nov 18 '12 at 10:01

Yes. you should by the Finder Automator Action pack from Ben Waldie. Here is his link:

He designed 20 new actions all just with the Finder (as well as others), and I have it and I can do exactly what you are describing with ease.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.