LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-06-2005, 10:38 AM   #1
kkatebian
LQ Newbie
 
Registered: Jan 2005
Location: Canada
Distribution: Debian (Sarge)
Posts: 20

Rep: Reputation: 0
renaming multiple files in general


Hi,

I've been really trying to "learn" linux recently but am having trouble renaming multiple files in a folder.

Specifically, I need to rename mp3 files from "tracknumber - trackname.mp3" to "trackname.mp3."

I've been reading about how to do this in general but have had difficulty with it as I do not know what I am doing. More specifically, I don't undertand the syntax.

Any help would be much appreciated.
 
Old 11-06-2005, 10:41 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
well as you've done there you either put them in quotes, or escape each space with a \ e.g. a\ file\ with\ spaces.txt there is no other syntax to wory about just to delete a normal file.
 
Old 11-06-2005, 10:47 AM   #3
kkatebian
LQ Newbie
 
Registered: Jan 2005
Location: Canada
Distribution: Debian (Sarge)
Posts: 20

Original Poster
Rep: Reputation: 0
I am somewhat confused by your reply.

Could you please elaborate?
 
Old 11-06-2005, 10:48 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
on what? maybe if you explain what you actually don't understand, what you've tried that didn't work etc...
 
Old 11-06-2005, 10:53 AM   #5
kkatebian
LQ Newbie
 
Registered: Jan 2005
Location: Canada
Distribution: Debian (Sarge)
Posts: 20

Original Poster
Rep: Reputation: 0
What I don't understand is how things of the type

for i in ls
do
x=$...

work.

more specifically, if I need to change the names of all of the files in a directory from "tracknumber - trackname.mp3" to "trackname.mp3", what will the variable x need to look like and where would I go from there?
 
Old 11-06-2005, 11:05 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
well you need to learn bash scripting then... there is no "x variable", that's just an example of using bash to achieve one of a billion goals.

to do *exactly* what you want, i'd guess at something like:
Code:
IFS="\n" for i in *.mp3
do
  mv -v "$i" "$(echo $i | cut -d\  -f3-)"
done
nothing clever there though, won't ensure that the file does start with a number then a dash etc...
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming multiple files linuxhippy Slackware 10 01-21-2011 01:53 AM
Renaming Multiple Files with a "." on the end of the filename dbowles Programming 1 05-09-2005 04:28 PM
Need help with shell script - renaming multiple files NiallC Linux - Newbie 25 07-04-2004 10:45 AM
Renaming multiple files with the same format Shr00mBoXx Slackware 7 06-20-2004 07:22 PM
Solution: renaming multiple files with spaces HawkeyeCoug Linux - Newbie 0 03-26-2004 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:15 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