LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux 101 - Renaming Multiple Files ????? (https://www.linuxquestions.org/questions/linux-newbie-8/linux-101-renaming-multiple-files-433187/)

perry 04-08-2006 08:04 PM

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:

Code:

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

KimVette 04-08-2006 08:15 PM

Do you have rename installed?
man rename ;)

Will this do what you need?

Code:

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
kim@kimp4:~/sandbo>


perry 04-08-2006 08:30 PM

thanks but "no go"
 
the problem is that the files have no extension already:

here's the file listing:
Code:

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

ps.
thanks "queen"

homey 04-08-2006 09:09 PM

This one seems to work ok....
Code:

rename "*" ".jpg" *
This one sort of works, but puts .jpg after all files. Probably could be tweaked to solve.
Code:

for i in *; do mv "$i" `basename "$i" `.jpg; done;


All times are GMT -5. The time now is 12:32 PM.