Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-26-2006, 12:36 AM   #1
LQ Newbie
Registered: Mar 2004
Location: Motor City, MI
Distribution: Redhat 7.3
Posts: 12

Rep: Reputation: 0
Batch renaming of dig. camera pics?

I am running a slackware file server in my house. I have ALOT of digital camera photos that I store in a directory. For simplicity sake, I am trying to write a script that will take the file, regardless of name(as long as it is a .jpg file), and change it to a sequential numeric name, i.e. 0001.jpg, 0002.jpg. My camera names the files with a very long name and I want to make something a bit shorter for sharing on my webpage with family. Thanks a bunch
Old 03-26-2006, 02:10 AM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
Incrementing a variable inside a for loop would probably be the easiest way, provided you don't have so many pictures that filename expansion causes a memory error.

For example:
index=1000  # Outside of quotes, preceding 0's disappear in variable values.
for picture in *.jpg; do
    mv "${file}" pic-${index}.jpg   
    index=$((${index}+1))         # increment value.
Make a backup of this directory before you do this, because a simple typo could wipe out all of your pictures.

Last edited by jschiwal; 03-26-2006 at 03:23 PM.
Old 04-09-2006, 05:00 AM   #3
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
mv "${file}" pic-${index}.jpg
Shouldn't this be
mv "${picture}" pic-${index}.jpg



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I download pics from my digital camera into kde? M$ISBS Linux - Hardware 2 11-15-2005 11:06 PM
Batch Renaming in bash xushi Programming 6 07-07-2005 03:24 PM
Best software for managing digital camera pics on Gnome? paul.nel Linux - Software 3 12-18-2004 04:43 AM
renaming batch of files linux_ub Linux - Newbie 6 10-27-2004 09:41 PM
Mount points for USB dvices incl. dig. camera Impaler Linux - Hardware 7 04-03-2004 01:07 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration