LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Closed Thread
  Search this Thread
Old 10-11-2003, 03:04 AM   #16
Col Panic
Member
 
Registered: Oct 2003
Distribution: Red Hat 9
Posts: 93

Rep: Reputation: 15

Quote:
Originally posted by arunshivanandan
i dont know why you guys make such a fuss abt something so trivial..............
heh....he asked for a Linux expert. So I called one and asked him.
 
Old 10-11-2003, 03:06 AM   #17
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
I dont see it as trivial. Why should a command work one way for a single file, and differently for multiples? It doesnt make sense.
 
Old 10-11-2003, 03:19 AM   #18
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
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.
 
Old 10-11-2003, 03:31 AM   #19
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
Yes, I get it...

however 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?
 
Old 10-11-2003, 04:04 AM   #20
fatgod
Member
 
Registered: Mar 2002
Location: Edinburgh, Scotland
Distribution: Suse 7.2, Gentoo 1.4, Solaris 9
Posts: 661

Rep: Reputation: 30
Quote:
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...

http://freshmeat.net/projects/ren/
 
Old 10-11-2003, 04:09 AM   #21
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Here you go:
Code:
#!/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;

werd up'

Last edited by micxz; 10-11-2003 at 04:18 AM.
 
Old 10-11-2003, 04:23 AM   #22
krussell
Member
 
Registered: Jul 2003
Location: dhaka
Distribution: Slackware 11 (fixed), MEPIS
Posts: 241

Rep: Reputation: 30
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
 
Old 10-11-2003, 01:32 PM   #23
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
Quote:
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.
 
Old 10-11-2003, 01:37 PM   #24
motub
Senior Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Gentoo (main); SuSE 9.3 (fallback)
Posts: 1,607

Rep: Reputation: 46
Quote:
Originally posted by oopicmaster
Yes, I get it...

however 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?
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.

But maybe you're perfect and never make any mistakes.
 
Old 10-11-2003, 01:41 PM   #25
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 47
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."
 
Old 10-11-2003, 01:47 PM   #26
motub
Senior Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Gentoo (main); SuSE 9.3 (fallback)
Posts: 1,607

Rep: Reputation: 46
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
 
Old 10-11-2003, 01:50 PM   #27
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
Quote:
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.
 
Old 10-11-2003, 01:54 PM   #28
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 47
Quote:
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).
 
Old 10-11-2003, 02:10 PM   #29
SLaCk_KiD
Member
 
Registered: Jan 2003
Location: Philly, PA
Distribution: Slackware 10.2
Posts: 97

Rep: Reputation: 15
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
 
Old 10-11-2003, 02:11 PM   #30
micxz
Senior Member
 
Registered: Oct 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Sounds like an echo in here, but:

What about "rename"?
 
  


Closed Thread


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
March of the Penguins movie - Thumbs up! J.W. General 2 07-10-2005 08:04 PM
Thumbs Up To Linux! redfedora88 LinuxQuestions.org Member Success Stories 3 03-22-2005 08:35 PM
Thumbs up for Suse 9.1 Wolfgang67 Linux - Distributions 18 08-05-2004 09:30 PM
2 thumbs up for linux. xode LinuxQuestions.org Member Success Stories 2 11-23-2003 06:57 PM
winex - 5 thumbs up! kazuni LinuxQuestions.org Member Success Stories 8 06-05-2003 08:43 PM


All times are GMT -5. The time now is 02:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration