> yup. 'T'would be a problem. However, the OP stated that each folder
> began with a unique number code (5 digits long).
It is a nit, but the OP said a "directory full of" not
necessarily "exclusively full of" as you have already corrected for by adding
the "find -type d".
> And here is the reason I avoid perl at all costs.
> They say there are no viruses for linux...
Do you say that because the bash solutions (repeated below) are soooo much
more intuitive? I'm just poking and not all that serious - I could've added
newlines and comments to the perl but then it wouldn't have been a one liner.
Somebody fluent in bash can understand these examples, but the same goes for
the perl solutions and somebody semi-fluent in perl. To somebody versed in
neither, both may as well be Greek even though they get the job done.
> for file in *; do
> new_name=$(echo $file | sed 's/^\([0-9]\{5\}\).*/\1/')
> echo Renaming "$file" to "$new_name"
> mv -v "$file" "$new_name"
> done
> find * -type d -maxdepth 0 | while read $d; do
> tgt=`expr substr $d 1 5`
> mv $d $tgt
> done
> do
> src=$i
> tgt=`expr substr $i 1 5`
> mv $src $tgt
> done
Personally I would fire up emacs, use dired mode on the directory, and do
a %-R which is dired-do-rename-regexp which interactive allows you to rename
files based on a regular expression. I have used this on many occasions - it
prompts for each file showing what you are renaming to as you go.
Paul
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/