Linux - GeneralThis 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
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.
I would not expect that to work on any system----In Bash, at least, the "*" expands to whatever Bash can see in the directory. The opportunity for ambiguity and confusion is huge.
try it this way:
Code:
for file in *.JPG; do mv $file $(sed 's/\.JPG//' $file).jpg; done
Well all the files in that one directory are of the .JPG extension and I want to move them all to a .jpg. For some reason the sw i am using only see .jpg not .JPG files.
So I dont see why the wild card would be bad here. Now I would never use it with rm
I have used the * on AIX many times for just such a thing and its fine. Why would it be a problem?
I also tried using the first 3 characters and it did not work
mv P100*.JPG P100*.jpg
This works on AIX but not in Ubuntu for some reason.
I have used the * on AIX many times for just such a thing and its fine. Why would it be a problem?
...
This works on AIX but not in Ubuntu for some reason.
There's also the rename command which I believe exists on most Linux distros, in this case one would do:
rename JPG jpg *.JPG
When i refer to SW i was talking about photobucket www site wont let me upload fiels of a .JPG extension. Only a .jpg (various other ones work but no caps) My camera puts the file with a JPG extension so I have to move all the pictures to a .jpg extension before uploading
ahhhh thank you that was the command I must have been thinking of. My bad.. rename not mv. I have used mv to move various files/dirs out of the way so they dont get over written. But you are right one at a time not with *.
Sorry brain cramp.
Ok may be not.. I must be doing something fundamentally wrong here
rename test test2
Bareword "test" not allowed while "strict subs" in use at (eval 1) line 1.
What the heck is "strict subs"
So I just tried a bunch of junk files and it does not work either..
(dont mind th e.bff just a test extension) If i do the files one at a time with mv command it works.
touch test.bff test2.bff test3.bff
me@mysys:/tmp$ rename *.bff *.abc
Bareword "test2" not allowed while "strict subs" in use at (eval 1) line 1.
Bareword "bff" not allowed while "strict subs" in use at (eval 1) line 1.
I can do a cp of the file to a new name
I can do a mv one file at a time.
I googled this error and see lots of hits but no real solution. My name doe snot have a space in it like some solution suggested so No clue here.
I tried a .txt extension and a .JPG jpg on empty files and nothing worked.
Try "rename --help" or "man rename" or read the previous post that had the answer.
rename JPG jpg *.JPG
Notice the list of files to change as the third argument.
The first argument is the original string. The second is the replacement string. The third ans subsequent arguments are the list of files to rename.
For example:
rename JPG jpg pic1.JPG pic2.JPG pic3.JPG
would rename just the three files you indicated.
Different distributions can have different programs called "rename". The one I have on mine is supplied as part of perl and uses the sed-and-perl-style "s///" syntax. So as suggested above, be sure to check the manpage.
And in fact, when I try to use the above style, I get the same error you do, so you're probably using perl rename also. This means that for you the command would be:
Code:
rename -nv "s/.JPG/.jpg/" *.JPG
I highly suggest using the -n flag to dry-run the renaming first, as well as the -v option for verbose output.
Well, mv is part of the gnu coreutils, so it's highly unlikely that any Linux distro will be using anything different. But outside of the basics there can sometimes be variations in which programs the distros offer. It's rare to have multiple programs with the same name though.
Other unixes (solaris, etc) also generally have their own versions of the core utilities. These are often less flexible than the gnu ones, since gnu has extended its versions with a great many options outside of the basic posix standards. This probably won't directly affect you very much, but you might want to keep it in mind when you search the web for scripting advice.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.