in reply to one liner to rename multiple files in a directory?
As applied to your case:ls -1 | perl -nle'$o=$_; s///; $n=$_; rename($o,$n)if!-e$n'
ls -1 *.avi | perl -nle'$o=$_; s/\[crap\]/Season1/; $n=$_; rename($o,$ +n)if!-e$n'
I find if!-e$n essential. One a couple of occasions, I've managed to delete all but one file in a directory without it.
There's a rename floating around script that takes regex patterns. That would be a better solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: one liner to rename multiple files in a directory?
by planetscape (Chancellor) on Feb 16, 2010 at 03:47 UTC | |
|
Re^2: one liner to rename multiple files in a directory?
by VGR (Acolyte) on Feb 17, 2010 at 10:31 UTC |