[ale] [OT] Cygwin mmv like tool

Todd Pike tpike at teepee-sw.com
Thu Jul 27 13:14:02 EDT 2006


Here's my "rewrite" of the linux "rename" command.  In some ways my
version is better but then again having a better gun sometimes allows us
to shoot a bigger hole in ourselves.



---snip---
#!/usr/bin/bash
# (c) Todd P. Pike
#
# Arg1 = regular expression to match (you quoted it right?)
# Arg2 = thing to replace it with. use "" to remove
# Arg3-n = list of files to rename
#
match="$1"
shift
rep="$1"
shift

for i ; do
        newname=`echo $i | sed "s/$match/$rep/"`
        if [ "$i" = "$newname" ] ; then continue ; fi
        if [ -e "$newname" ] ; then
                echo ERROR:  $newname exists $i not renamed
                continue
        fi
        mv "$i" "$newname"
done
---snip---

> All,
>
> Anyone know a tool for rename a bunch of files at one whack in the
> cygwin environment?
>
> ie.  I want to strip the abc prefix off of a bunch of abc* files.
>
> I thought mmv was in there and it can do the job, but I'm not finding it.
>
> Maybe it has been superseeded?
>
> Thanks
> Greg
> --
> Greg Freemyer
> The Norcross Group
> Forensics for the 21st Century
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>




More information about the Ale mailing list