Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mv and multiple files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Lockup
Guru
Guru


Joined: 25 Jul 2002
Posts: 430

PostPosted: Mon Jan 20, 2003 7:02 pm    Post subject: mv and multiple files Reply with quote

is there some kind of alternative to 'mv' (or another shell i dunno...) that supports multiple files on move? for example:

Code:

mv *.mp3 *.blah


kinda like old-style dos...
i looked around a bit but im not even sure WHAT to look for(the words...:P[/code]
Back to top
View user's profile Send private message
aja
l33t
l33t


Joined: 26 Aug 2002
Posts: 705
Location: Edmonton, Canada

PostPosted: Mon Jan 20, 2003 7:09 pm    Post subject: Reply with quote

The Linux Cookbook mentions a perl script called chcase for that use. A google would probably turn it up.
Back to top
View user's profile Send private message
gzaector
Tux's lil' helper
Tux's lil' helper


Joined: 24 Nov 2002
Posts: 132
Location: 304

PostPosted: Mon Jan 20, 2003 7:35 pm    Post subject: Reply with quote

you could try putting everything into a directory then copying that, then deleting it

Code:

cp -r dir dest; rm -rf dir


just a suggestion

-gza
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Mon Jan 20, 2003 8:38 pm    Post subject: Reply with quote

Check out rename, which is part of the util-linux package.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Lockup
Guru
Guru


Joined: 25 Jul 2002
Posts: 430

PostPosted: Mon Jan 20, 2003 11:05 pm    Post subject: Reply with quote

thanks ill look into rename and that perl script :)
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Mon Jan 20, 2003 11:34 pm    Post subject: Reply with quote

Another method is using shellscripts.

Code:

for i in *.mp3
do
 mv $i `basename $i .mp3`.blah
done


This renames all your .mp3 files to .blah.
Just type in the command at yhe command prompt and hit enter to run it.

Erik
_________________
'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
Back to top
View user's profile Send private message
Kaali
Tux's lil' helper
Tux's lil' helper


Joined: 12 May 2002
Posts: 80

PostPosted: Tue Jan 21, 2003 12:43 am    Post subject: Reply with quote

ebrostig wrote:
Another method is using shellscripts.

Code:

for i in *.mp3
do
 mv $i `basename $i .mp3`.blah
done


This renames all your .mp3 files to .blah.
Just type in the command at yhe command prompt and hit enter to run it.

Erik


Or use mostly unknown feature in Bash to tweak ebrostigs code a bit:
Code:

for i in *.mp3; do mv $i ${i/.mp3/.blah}; done
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Tue Jan 21, 2003 12:47 am    Post subject: Reply with quote

Great!
I was not aware of that feature :oops:
I'm not doing enough shell programming these days.

Erik
_________________
'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.'
Back to top
View user's profile Send private message
bdonlan
n00b
n00b


Joined: 21 Jan 2003
Posts: 44

PostPosted: Tue Jan 21, 2003 12:49 am    Post subject: Not directly... Reply with quote

Try:

Code:
for mp3 in *.mp3; do mv "$mp3" "$(echo $mp3 | sed 's/[.]mp3$/.blah')"; done
Back to top
View user's profile Send private message
linut
n00b
n00b


Joined: 07 Dec 2002
Posts: 18

PostPosted: Tue Jan 21, 2003 10:09 pm    Post subject: Reply with quote

Quote:
is there some kind of alternative to 'mv'

You might like mmv or ren. They are in portage.
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Wed Jan 22, 2003 12:10 am    Post subject: Reply with quote

find and xargs are another alternative to the shell scripting approach.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum