Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well I have a love of files that I want then to have the .jpg ext in windows I would just
Code:
move .\* .\*.jpg
that would fix that. I thought I could use the mv command but that just put everything in a new folder called .jpg. I see that the mv command is just for renameing folders
mv can be used for individual files OR directories. To contradict Mr Shakespeare the fault likes in your star(s).
If you mv file file.jpg it would work just fine.
However you told it to move * which means EVERYTHING to jpg so it assumed you meant you wanted to move all the files to a directory. If it HAD worked the way you told it then you'd end up with only a single file named jpg which would be the LAST file it found which would be even worse.
To rename all the files you could do:
for file in `ls [a-z]*`
do mv $file ${file}.jpg
done
The first line says to get a list of files that start with any character a-z (this helps to exclude files that start with . such as .bashrc that you do NOT want to rename as jpg files.). Note the characters here are backticks (same key as ~) rather than single quotes.
You put the braces around file in the do line so that it knows the variable is only $file and not $file.jpg which you haven't defined.
Last edited by MensaWater; 06-02-2007 at 04:26 PM.
Well did I do some thing wrong, it dod not rename thises files.
Code:
[al@al cody2]$ for file in `ls [a-z]*`
> do mv $file ${file}.jpg
> done
ls: cannot access [a-z]*: No such file or directory
[al@al cody2]$ ls
00080447d01 193D1572d01 34C705E1d01 5408B326d01 65C8052Dd01 760A240Ad01
it did reame 90 files. now what do I do and I move them to a new folder.
but 600 files is a lot of files to name.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.