LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-01-2006, 09:55 PM   #1
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Script to change file names with incremental counter.


I'm getting ready to rip, and convert to .mp3, a 64 disk set, the KJV Bible. The cd's are not on freedb so the filenames come out track_01.wav, track_02.wav, etc.

This is the script, I'll use to rename them during the conversion ... with the trouble spot marked XXX.
Code:
for file in tmp/*.wav; do lame -m m -V 7 "$file" "Genesis XXX.mp3"; done
I need a way to replace XXX with an incremental counter so they'll be named Genesis 1.mp3, Genesis 2.mp3, etc. It would be nice if I could precede 1 digit numbers with a 0, (Genesis 01, etc.) to keep things in order by filename, but I can live without that. A complicating factor is that I need to start the counter at an arbitrary point. The 2nd disk will rip as track_01.wav again, but it needs to be converted as 'Genesis 23.'

I could also just use a script to change the filenames en masse before or after the conversion if that seemed like the logical way to go about it, but it still seems to me that I'll need that variable to be applied as part of the file name.
 
Old 05-01-2006, 10:26 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Try something like this:
Code:
MP3NO=1
for file in tmp/*.wav
    do lame -m m -V 7 "$file" "Genesis $MP3NO.mp3"
    MP3NO=$(($MP3NO+1))
done
Just change MP3NO to be the new starting number for each batch.
 
Old 05-01-2006, 10:43 PM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
Thanks a ton. Given that much of a start, I think I can do it.
 
  


Reply



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 to change file names to uppercase in a directory konramesh Linux - General 4 06-16-2009 06:13 AM
Script to change names of files in a directory geomonap Linux - General 2 12-03-2004 03:04 PM
change file names to lowercase. david_wliu Linux - General 4 03-10-2003 01:17 PM
change file names to lowercase. david_wliu Programming 2 03-10-2003 12:59 PM
Help with a Script for Trimming last 2 letters of file names eagletech Linux - Newbie 3 11-13-2002 06:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:08 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration