[Linux-disciples] Troubles with 'rename'
Stephen R Laniel
steve at laniels.org
Mon Jun 27 23:46:45 EDT 2005
On Tue, Jun 21, 2005 at 04:14:58PM -0400, Stephen R Laniel wrote:
> Your script's trick is to run the rename command once, on
> all the files within a given directory. I doubt it would be
> so hard to do this with 'find'. Though I'm curious. Once I
> get the find approach working, I'll do a test. If there's
> any performance hit from your script, it's that it's calling
> 'lr' recursively, which may lead to a blown stack. But
> that's probably not a huge concern.
Turns out that it's easy to do with 'find' and 'rename':
#!/bin/bash
PATH=/usr/bin
find -depth -execdir rename 's/ /_/g' '{}' \;
-depth is necessary so that children get renamed before
their parents. -execdir is necessary so that find changes
into the directory before renaming it. Changing the PATH is
necessary because -execdir won't let you go until '.' is out
of the PATH.
--
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050627/d0cf3243/attachment.pgp
More information about the Linux-disciples
mailing list