Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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'll explain.
mv is move.it is for moving a file to another location.fine??
so 'mv *.jpg /blahblah' will move every .jpg stuff to /blahblah',with the same name.you cant move all the files to another file.but moving a single file abc.jpg to bbc.jpg is possible.but 'mv *.jpg /blahblah/* wont work.i guess you got it.
--arun.
Originally posted by oopicmaster IMHO it is a dumb way to do things.
Why should a command behave differently just because It needs to operate on more that one file?
Dont you find that to be just a wee bit.... kooky?
mv is not meant for renaming files. It was made to move them If you want to rename files then get ren like Col Panic said. ren is far superior to the MS-DOS (and hence windows) move command anyway, with MS-DOS a typo can mean all your files disappear into one file. Surely you've done that before, I certainly have.
... from the ren man page:
" The multiple rename is performed
safely, i.e. without any unexpected deletion of files due
to collisions of replacement names with existing names, or
with other replacement names. Also, all error checking is
done prior to doing any renames, so either all renames are
done, or none."
Coolness, and it's free
you can get it from here too, if you haven't tried it already that is...
#!/bin/bash
#
# by Micxz [at] hotmail.com
#
if [ -z "$NAME2" ]; then
echo 'You must export a name to rename files first (eg. "export NAME2=RENAMETO")'
exit 1
fi
for x in *; do
echo -n $x;
echo -ne '\000'
echo -n `echo $x | cut -f 1 -d '.'`
echo -n "$NAME2."
echo -n `echo $x | cut -f 2- -d '.'`;
echo -ne '\000'
done | xargs -0 -n2 mv
Be careful if you don't understand what this script is doing then maybe you should not be running it.
Your building a list of the filenames followed by the name we want to mv it to. seperated by NULL characters in the current directory. Then we feed the entire list to xargs witht the switchs to let mv have two arguments
this would be the hard way. As the others mentioned "rename" does the same;
oopicmaster should know that ALL major operating systems are extentions/follower of UNIX. dos commands are nothing but variations of unix commands. so anything u do in windows especially in command prompt, can be done a hundred times better in linux/unix. please don't make me laugh saying that u can do more in command prompt in windows than in linux. LOL again
mv is not meant for renaming files. It was made to move them
Yes but at the single file level it allows you to move a file from one filename to another.
It would be simple, and much more intuitive if the command worked the same way for multiple files.
OR,
It should only allow you to move SINGLE files to a directory as well. Changing behaviour between single vs. multiple is IMHO inconsistent and poor design
Quote:
oopicmaster should know that ALL major operating systems are extentions/follower of UNIX.
Yes they took UNIX and made it better, and easier to understand, thats why other OS's have dominated the PC market.
IMHO the mv command shouldnt exist at all!
Moving a file should just be a switch on the copy command! Moving is just copying where you delete the source file after copying. I shouldnt need 2 completely different commands for that.
Its just like the rm and rmdir commands... complete waste... especially when rm -rf can remove a directory too! Its like the designers of Unix had nothing better to do than make up a bunch of extra commands.
why do you folks waste your time responding to an obvious troll? plenty of people could use your expertise for help with actual problems. if he can't man or figure out simple mv or ren commands, let him go back to windows, "where everything is better and intuitive."
No, because it is actually a good thing to be very aware when you're working with a single file rather than what might actually be thousands of files.
No matter how you slice it, moving files around is dangerous. Whether you move them to different filenames or to a different directory, either way you can screw up your system.
Originally posted by motub Because you never know when a new user who's "on the fence" might read this thread, and have the same questions.
I'm sure that none of us think that we're going to "convince" the troll, but you've got to think of the future generations of Linux users
i'm thinking about the current generation who need actual help. and i doubt a thread about moving files is going to convince anyone one way or another about whether they should use linux (at least it shouldn't).
Actually if you want to get specific about the comparison between cp and mv commands, the way mv writes, i dont think that the file is actually copied from one location to another, and then deleted. the data isnt actually moved around on disk unless you move it to /usr/local, or another partition that you have set up besides your root one. it has more to do with where the file points to on disk, and not just that its in a different directory....hence why you need to defrag once in a while
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.