Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 have a load of files in a directory. They all have names like:


How could I bulk rename them to


i.e. get rid of the prefix before _, and then remove the first leading zero?


share|improve this question
Are all prefixes the same APP_, or different? – Daniel Beck Feb 10 '11 at 22:17
for file in APP_*.gif; do
    mv "$file" "$new"
share|improve this answer
shopt -s extglob; for f in in APP_*.gif; do mv "$f" "${f##app_?(0)}"; done
share|improve this answer

If the actual names are not important, and simply want all of the photos to have unique, yet organized names, you can open automator and create the following automator action.

This is what I do, and then save it as a service (assuming you have 10.6, snow leopard) then you can select any group of files in finder, right click and select . This version prompts the user for the prefix of each file then uses that value (instructions on referencing a variable in an automator action here), but you can also use the rename action alone to number files sequentially.


share|improve this answer
Why a down-vote? I answered the question. – finiteloop Feb 10 '11 at 22:52
The numbers seem to be relevant. Otherwise it'd be a simple "how do I make these sequential" question. – Daniel Beck Feb 11 '11 at 6:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .