LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 03-26-2006, 01:36 AM   #1
fbfd1338
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
-Kevin
 
Old 03-26-2006, 03:10 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
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:
Code:
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.
done
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 04:23 PM.
 
Old 04-09-2006, 06:00 AM   #3
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

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


Reply

Tags
renaming


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-16-2005 12:06 AM
Batch Renaming in bash xushi Programming 6 07-07-2005 04:24 PM
Best software for managing digital camera pics on Gnome? paul.nel Linux - Software 3 12-18-2004 05:43 AM
renaming batch of files linux_ub Linux - Newbie 6 10-27-2004 10:41 PM
Mount points for USB dvices incl. dig. camera Impaler Linux - Hardware 7 04-03-2004 02:07 AM


All times are GMT -5. The time now is 01:15 PM.

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