Skip to main content

Thread: Renaming files in bulk


i have following files:

# ls -1 *.mp3
megadeth - killing business...and business good! - 01 - last rites-loved death.mp3
megadeth - killing business...and business good! - 02 - killing business...and business good.mp3
megadeth - killing business...and business good! - 03 - skull beneath skin.mp3
megadeth - killing business...and business good! - 04 - these boots.mp3
megadeth - killing business...and business good! - 05 - rattlehead.mp3
megadeth - killing business...and business good! - 06 - chosen ones.mp3
megadeth - killing business...and business good! - 07 - looking down cross.mp3
megadeth - killing business...and business good! - 08 - mechanix.mp3


i want rename to:

01 - last rites-loved death.mp3
02 - killing business...and business good.mp3
03 - skull beneath skin.mp3
04 - these boots.mp3
05 - rattlehead.mp3
06 - chosen ones.mp3
07 - looking down cross.mp3
08 - mechanix.mp3


queastion how ???

here rnd far:


# ls -1 *.mp3 | sed "s/"megadeth\ -\ killing\ is\ my\ business\.\.\.and\ business\ is\ good\!\ -\ "/ /g"
01 - last rites-loved death.mp3
02 - killing business...and business good.mp3
03 - skull beneath skin.mp3
04 - these boots.mp3
05 - rattlehead.mp3
06 - chosen ones.mp3
07 - looking down cross.mp3
08 - mechanix.mp3


so give me output want on console...so need have him rename files...this tried:

# ls -1 *.mp3| sed "s/\("megadeth\ -\ killing\ is\ my\ business\.\.\.and\ business\ is\ good\!\ -\ "\)\(.*\)/mv & \2/g"
mv megadeth - killing business...and business good! - 01 - last rites-loved death.mp3 01 - last rites-loved death.mp3
mv megadeth - killing business...and business good! - 02 - killing business...and business good.mp3 02 - killing business...and business good.mp3
mv megadeth - killing business...and business good! - 03 - skull beneath skin.mp3 03 - skull beneath skin.mp3
mv megadeth - killing business...and business good! - 04 - these boots.mp3 04 - these boots.mp3
mv megadeth - killing business...and business good! - 05 - rattlehead.mp3 05 - rattlehead.mp3
mv megadeth - killing business...and business good! - 06 - chosen ones.mp3 06 - chosen ones.mp3
mv megadeth - killing business...and business good! - 07 - looking down cross.mp3 07 - looking down cross.mp3
mv megadeth - killing business...and business good! - 08 - mechanix.mp3 08 - mechanix.mp3

so show can run "mv" , reame files way want. but...there lots of spaces in each file, , hence when append "|sh" above command have him rename files, "mv" command failing.


suggestions please.
btw, tried exploring perl "rename" command, not understand it's regex.

thnx.



Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] Renaming files in bulk


Ubuntu

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO