Results 1 to 3 of 3

Thread: Mass adding of numbered prefix (01, 02, 03, etc ) to files in a folder

  1. #1
    Join Date
    Jun 2013
    Beans
    1

    Mass adding of numbered prefix (01, 02, 03, etc ) to files in a folder

    Hello Linux Experts,

    I would like to add a numbered prefixes to all my folders in a folder.

    For example, I have the following
    Picture_a.jpg
    Picture_b.jpg
    Picture_c.jpg
    Picture_d.jpg
    Picture_e.jpg

    I want to have

    01_Picture_a.jpg
    02_Picture_b.jpg
    03_Picture_c.jpg
    04_Picture_d.jpg
    05_Picture_e.jpg

    I have 91 photos that I want to rename in this fashion. Thanks!

  2. #2
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Mass adding of numbered prefix (01, 02, 03, etc ) to files in a folder

    You could use PyRenamer.
    Cheesemill

  3. #3
    Join Date
    Apr 2012
    Beans
    5,609

    Re: Mass adding of numbered prefix (01, 02, 03, etc ) to files in a folder

    or if you like shell scripting, maybe a loop like this (the 'echo' in it stops it from actually doing the renames - kind of like a dry run)

    Code:
    i=0; for pic in *.jpg; do printf -v prfx '%02d' ${i}; echo mv "${pic}" "${prfx}_${pic}"; ((++i)); done
    mv Picture_a.jpg 00_Picture_a.jpg
    mv Picture_b.jpg 01_Picture_b.jpg
    mv Picture_c.jpg 02_Picture_c.jpg
    mv Picture_d.jpg 03_Picture_d.jpg
    mv Picture_e.jpg 04_Picture_e.jpg
    mv Picture_f.jpg 05_Picture_f.jpg

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •