You are not logged in.
I've never used sed before but my problem is this:
1. I have about 40+ files all with the extension .flv.mp3 in a directory.
2. I want to change the extension from .flv.mp3 to just .mp3.
What's the best way of doing this?
Last edited by PingPing (2009-10-10 15:30:53)
Offline
man rename
Offline
rename .flv.mp3 .mp3 *.flv.mp3
and it may be solved.
but using sed is a bit different but very possible.
you can create a script with a loop (for/while).
for all of those files, u just need to do this:
#! /bin/bash
# by quarkup™for filename in `ls *.flv.mp3`
do
target_name = `echo $filename | sed -e 's|\.flv\.mp3$|\.mp3|g'`
mv $filename $target_name
donereturn 0
quite simple
anyway, you got the package "file-rename-utils" in the AUR which provides you the "mv_sed" executable (script) and another ones which may help you on another times.
Last edited by quarkup (2009-10-10 15:15:10)
If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.
Simplicity is the ultimate sophistication.
Offline
or in bash-isms only:
#!/bin/bash
for file in *.flv.mp3; do
mv "$file" "${file%.mp3}"
done
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
Thanks very much everyone. I went for the simplest option:
rename 's/flv\.mp3/mp3/' *.flv.mp3
but many thanks for the shell scripting advice. I'm sure I'll have cause to use it in the future.
Offline