Awww Mom,
Why can't I have a blog?
Everyone else is doing it...
| October 2005 | ||||||
| S | M | T | W | T | F | S | 1 |
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
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:
|
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. |