in reply to Yet another perl-rename tool
ls -1 a b c AThe script would rename 'a' to 'A' and the former contents of 'A' would be lost.
For more fun, it is even possible to accidentally rename a file early in the list into a filename that is present later in the list, e.g. if you want to add 9 to numbers present in photo filenames:
ls -1 photo-1 photo-2 photo-3 photo-4 photo-5 photo-6 photo-7 photo-8 photo-9 photo-10should become
photo-10 photo-11 photo-12 photo-13 photo-14 photo-15 photo-16 photo-17 photo-18 photo-19The regexp would look somewhat like s/(\d+)/sprintf('%d', $1 + 9)/e (untested...) The loop first turns photo-1 to photo-10 (clobbering the original photo-10), later the clobbered photo-10 will become photo-19. The old photo-10 is gone, a new photo-10 is nowhere to be found and the new photo-19 is equal to the old photo-1. Confusion!
Maybe it is better to build a list of filename replacements first and check this list for these issues before doing any permanent change.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Yet another perl-rename tool
by wazoox (Prior) on Feb 25, 2009 at 14:35 UTC | |
by chb (Deacon) on Feb 25, 2009 at 14:58 UTC | |
by parv (Parson) on Feb 26, 2009 at 02:53 UTC |