[RDD] Batch-renaming of audio files

David Klann dklann at linux.com
Sat Jun 11 11:37:14 EDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Watch the text wrap in the script! The line that starts with the word
"changes" should actually start with "echo"...




> #!/bin/sh
> 
> renameDir=/full/path/to/dir/with/audio/tracks
> 
> # find all regular files containing two-digit-and-a-hypen prefix
> find ${renameDir} -type f -iname '[0-9][0-9]-*' -print | while read
> file do
> 
>   # the '##/??-' syntax strips the full path and the preceeding "XX-"
>   # the 'tr -s' command converts spaces and hyphens to underscores
>   newName=$(echo "${file##*/??-}" | tr -s '[- ]' '_')
> 
>   # run this without the preceeding 'echo' to actually perform the
>   changes echo mv ${file} "${renameDir}/${newName}"
> 
> done
> # End
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iF4EAREIAAYFAk3zi6oACgkQZtxZ++32cNiTHgEAuOBy5d0lwuXgr+8c0LHZhpy4
FU6Ssd716jva/VUTODoBALOJ+5VkChwwKRwLVxI04868qUjaCBKMO9epVb57jH+q
=r68f
-----END PGP SIGNATURE-----


More information about the Rivendell-dev mailing list