You are here

  1. Blogs
  2. » charles's blog

renameutils: preserving my sanity

Ever been faced with a collection of files that need renaming and nearly gone mad from trying to do it manually? Lots of typing mv, or lots of right click -> rename. Enter qmv, part of renameutils. Suppose we have a bunch of mp3s that require renaming:

$ ls<br />
track10.mp3  track12.mp3  track2.mp3  track4.mp3  track6.mp3  track8.mp3<br />
track11.mp3  track1.mp3   track3.mp3  track5.mp3  track7.mp3  track9.mp3

qmv allows us to edit the names in a text editor, defaulting to your $EDITOR, but you can specify a different editor if you prefer.

$ qmv --editor=emacs *<br />

USing QMV

In the default format, there are two columns, the left being the original file name and the right being the names of the destinations, allowing the name mapping to be explicit at all times

Using QMV 2

On saving and closing the file, qmv follows the mapping you laid out.

$ ls<br />
01-Kill_The_lights.mp3  05-Redstars.mp3       09-To_Die_For.mp3<br />
02-Goodnight.mp3        06-Looking_Glass.mp3  10-Walking_With_Strangers.mp3<br />
03-Falling_Down.mp3     07-Science.mp3        11-Weekend.mp3<br />
04-Unfamilliar.mp3      08-Remember_Me.mp3    12-Movie.mp3

Of course there are all kinds of tricks you can do with find/replace and regular expressions, but with the default format the input filenames get in the way, but qmv has a trick up its sleeve:

qmv -f destination-only *

Using QMV 3

Now we can use M-x replace-string to replace the '-' with '-The_Birthday_Massacre-Walking_With_Strangers-' to add in the band and album name. Of course with the power of some text editors the possibilities are endless.

Also included in the renameutils package are imv, which uses readline for a less complex but still interactive move, the equivalents for copying, qcp and icp, and deurlname which replaces url-encoded characters with the decoded character.

Subject: 

Add new comment

BBCode, html and code systax highlighting

  • Allowed HTML tags: <a><img> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><strike><hr>
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text. URLs will automatically be converted to links.

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

My Band

LinuxCounter.net

Creative Commons License
Except where otherwise noted, work is licensed under a Creative Commons Licence and is the work and opinion of the credited author(s).

Powered by Drupal

My Facebook


Charles Elwood's Facebook profile