Awww Mom,
Why can't I have a blog?
Everyone else is doing it...



October 2005
SMTWTFS
      1
2345678
9101112131415
16171819202122
23242526272829
3031     




Sunday, October 2, 2005

Given what a pain in the ass iTunes can be when working with mp3 files not of its own making, I've had to rename certain files with a prefix so I can manage them better. Here's a script to rename files with a given prefix. Invoked so:

> prerename.sh

Example:
>prerename.sh "*.mp3" "CD-1-"


Be sure to keep the arguments inside double quotes so the renaming can handle spaces, otherwise the shell will expand them into arguments for you. Oops.

#!/bin/bash
# Program: prerename.sh
# Author: Spastic Mutant mutant@spasticmutant.com
#
# Rename a bunch of files with the given prefix.
# e.g. > ./testrename "fo*" "myprefix"
# renames foo\ 5 to myprefixfoo\ 5 .
#

prefix=$2

for i in $1 ;
do
echo "starting with: " $i
mfile=$(echo $i | sed 's/\.\///')
echo $mfile
echo "finalname:" $prefix$mfile
mv "$mfile" "$prefix$mfile"

done

Posted by SpasticMutant @ 12:34 PM PST [Link]

[Archives]

Search entries:






Symbol for
Universal Recyclables DISCLAIMER: This web page was constructed with 100% recycled electrons (or, during shortages, at least 35% post-consumer electrons). No electrons were harmed in the making of this web page, although several were accelerated against their collective will. No files have been charged. And Remember: the only Good Cow is a Dead Cow.

© 2000, 2001, 2002 Spastic Mutant Productions. All Rights Reserved.