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.
In reply to Re: Yet another perl-rename tool
by chb
in thread Yet another perl-rename tool
by Tanktalus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |