Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

For example,I have 20 pictures downloaded from the Internet. They have some crazy names like "XFGHDHR345" or "SDEREWQ230", and I want to name them:

"Picture 1"
"Picture 2"
"Picture 3"
"Picture 4"
"Picture 5"
.....
"Picture 20"

I don't want to type them one by one. I want to change their names at once.

Is there a way to do this?

share|improve this question
    
For those who have Photoshop, it does a really nice job at easily doing just this. –  bassplayer7 Mar 29 '13 at 14:46
add comment

5 Answers 5

up vote 15 down vote accepted

Using the built-in tool "Automator", you can define a workflow to batch rename files.

To do that, you will have to:

  1. Open Automator find it using Spotlight or in /Applications
  2. Create a new Workflow
  3. Type get into the search field enter image description here

  4. Scroll to the bottom of the list of items and drag Get Specified Item from the Files & Folders actions list on the left panel and drop it into the right panel

  5. Click the Add button and find your files
  6. Add the Sort Finder Items action followed by Rename Finder Items
  7. It the "Rename Finder Items" panel, select "Make Sequential" and "Add number to" Picture
  8. Hit the play button and you should be done

Have a look here or here for an example tutorials on your specific renaming task at hand. An excellent overview of what Automator does and how powerful (and simple) it can be as a personal assistant - see the web page http://macosxautomation.com/automator/index.html

share|improve this answer
    
Nice example of Automator - it's clearly intended for this case to clean up photo files. I'll add in the grandfather of Automator resources, Sal Saghoian's macosxautomation.com/automator/index.html –  bmike Mar 29 '13 at 13:45
    
+1: Didn't know you could do that with Automator. –  jaume Mar 29 '13 at 14:52
add comment

Yes, you can use Terminal:

  1. Move all your pictures to a temporary folder on the Desktop, for example Temp.

  2. Open Applications>Utilities>Terminal.app.

  3. Change directory to Temp:

    cd ~/Desktop/Temp
    

    where ~ is expanded to your home directory (that is, /Users/<yourusername>.)

  4. Run this compound shell command:

    n=1; for file in *; do mv "$file" "Picture $n"; let n++; done
    

    where:

    • for ...; do ...; done loops over your 20 files. file is the variable that holds filenames. See this article for more information.

    • n, initially set to 1 and increased by one in every iteration with let n++, is the integer suffix for the renamed files.

    • mv "$file" "Picture $n" renames the files. $n is the value of variable n.

    The shell command is equivalent to:

    mv SDEREWQ230 "Picture 1"
    mv XFGHDHR345 "Picture 2"
    mv YWUU7738DT "Picture 3"
    (...)
    

For more information on the bash shell see man bash. For more information on shell scripting see this guide at the Apple developer website.

share|improve this answer
1  
This is a much better explanation of using the shell to handle file edits than we have over there. Granted, that example is a simple edit - all files with pattern ABC need to be renamed to 123 so this has to be slightly more complex. +2 if I had two votes. –  bmike Mar 29 '13 at 13:43
    
@Jadav I don't think you're counting keystrokes correctly here. Even if you key around the Finder and hit Enter on each instead of clicking, it's still more efficient to run the script, even if you're only doing 20 pictures. –  zigg Mar 29 '13 at 22:53
    
Compared to the Automator solution ! But newer than less that is some impressive programing on your side. –  Jadav Mar 29 '13 at 22:59
add comment

If you don't want to use the Terminal or Automator, there are commercial apps with a GUI for doing this. One is A Better Finder Rename, which has a free trial version.

share|improve this answer
    
+1 for ABFR -- while it does cost $20, it quite easily handles this particular task, where the initial filenames are random, and many other more complex batch renaming tasks besides. –  scottishwildcat Mar 29 '13 at 17:28
    
I always like to point out the option of using commercial utility apps with a nice GUI because many casual users find that using the Terminal or Automator is too difficult for some tasks. ABFR is an example of a refined product that is very flexible and works well. For many users, spending $20 is a better option than learning the complexities of rarely-used text commands. You can decide which you would rather use. –  Wheat Williams Apr 3 '13 at 13:37
add comment

If you want to zero-pad the numbers or if the files have different extensions:

i=1; for f in *; do mv "$f" Picture\ $(printf %03d $i).${f#*.}; let i++; done

More examples:

# lowercase (Bash 4) and replace spaces with underscores
for f in *; do f2=${f,,}; mv "$f" "${f2// /_}"; done

# number based on modification date
IFS=$'\n'; i=1; for f in $(ls -rt *.jpg); do mv "$f" $(printf %04d $i).jpg; let i++; done

# file-5.jpg to file-005.jpg
for f in *; do b=${f%.*}; x=${f#*.}; mv "$f" "${b%-*}-$(printf %03d ${b#*-}).$x"; done
share|improve this answer
    
HOLA @Lauri Ranta, was that English :), or is the computer going up in smoke after doing that to it ? –  Jadav Mar 29 '13 at 23:01
add comment

I will recommend here NameChanger application. Its very simple and fast to use. Very good options given there for renaming files with different criteria.

share|improve this answer
add comment

Your Answer

 
discard

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.