Latest LQ Deal: Linux Power User Bundle
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 04-08-2006, 08:04 PM   #1
Registered: Sep 2003
Location: USA & Canada
Distribution: Slackware 12.0
Posts: 978

Rep: Reputation: 30
Linux 101 - Renaming Multiple Files ?????

Ok, outside of partitioning drives and installing unlimited versions of linux and doing everything from low level formats to setting up dvd players to work with linux... still... and i mean still... i don't know how to do a simple wildcard command similiar to the following:

in ye old dos world i'd write

ren * *.jpg

or if it was batch i'd go

for %%f in (*) do rename %%f %%f.jpg 

and such...
needless to say i have a list of jpg files that don't have the jpg extension, but thats beside the point. the question is, what are the linux (or *nix) equivalents to "ren * *.jpg"

thanks much

- perry
Old 04-08-2006, 08:15 PM   #2
Senior Member
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
Do you have rename installed?
man rename

Will this do what you need?

kim@kimp4:~/sandbo> ls -l
total 0
-rw-r--r--  1 kim users 0 2006-04-08 21:12 bar.txt
-rw-r--r--  1 kim users 0 2006-04-08 21:12 foo.txt
kim@kimp4:~/sandbo> rename .txt .html *
kim@kimp4:~/sandbo> ls -l
total 0
-rw-r--r--  1 kim users 0 2006-04-08 21:12 bar.html
-rw-r--r--  1 kim users 0 2006-04-08 21:12 foo.html
Old 04-08-2006, 08:30 PM   #3
Registered: Sep 2003
Location: USA & Canada
Distribution: Slackware 12.0
Posts: 978

Original Poster
Rep: Reputation: 30
thanks but "no go"

the problem is that the files have no extension already:

here's the file listing:
051B4EAFd01*  330CEDA4d01*  4E83E243d01*  7A5EF4DDd01*  D4D5D720d01*
1167761Ed01*  3390ABA5d01*  4E84E243d01*  81DFB186d01*  D8094EAEd01*
14DEABA5d01*  352D4B6Bd01*  4E85E243d01*  8201F745d01*  DFA8B099d01*
163C3BA3d01*  3C29F631d01*  4E8EE243d01*  839FB1CDd01*  E8607F23d01*
1DC3ABA5d01*  3C2AF631d01*  56FA2CF0d01*  83BFB11Fd01*  E8627F23d01*
2366CF0Bd01*  3C2BF631d01*  5728EDA4d01*  85039674d01*  E8647F23d01*
2409CF0Bd01*  3C30F631d01*  57B4ABA5d01*  8CAFD15Cd01*  E8677F23d01*
25068152d01*  3C31F631d01*  586FEDA4d01*  8EE5D2FFd01*  F11C7629d01*
25FFABA5d01*  3CD7ABA5d01*  6507E200d01*  91167601d01*  F934DBF0d01*
27B68155d01*  3F8345BFd01*  6507E201d01*  AC1FD728d01*  F938DBF0d01*
27E0ABA5d01*  41407BE6d01*  6507E203d01*  B30D69DBd01*  F93ADBF0d01*
2C1DD725d01*  4147EDA4d01*  6507E207d01*  BAE0D19Fd01*  F93EDBF0d01*
2C79F626d01*  4314A14Ad01*  6C32E143d01*  BC0A95ACd01*  F93FDBF0d01*
2C7AF626d01*  4358EDA4d01*  6DD62A49d01*  BCC295ACd01*  doit*
2C7CF626d01*  47ABE6C1d01*  6E82E144d01*  BD8293FFd01*
32424B6Bd01*  4E80E243d01*  7066EDA4d01*  C3852B3Bd01*
so what i need now is a way to tell "rename" to change file names that don't already have an extension

hope this hoplessly simply problem is hopefully simpler to solve than one world think...

i guess all i got to do is play the game

thanks again

- perry

thanks "queen"
Old 04-08-2006, 09:09 PM   #4
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
This one seems to work ok....
rename "*" ".jpg" *
This one sort of works, but puts .jpg after all files. Probably could be tweaked to solve.
for i in *; do mv "$i" `basename "$i" `.jpg; done;


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
renaming multiple files linuxhippy Slackware 10 01-21-2011 01:53 AM
renaming multiple files in general kkatebian Linux - General 5 11-06-2005 11:05 AM
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 > Forums > Linux Forums > Linux - Newbie

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