10-27-04 10:45 PM
paul <paulbon@polarcomm.com> writes:
>I am looking for an automated way to rename files. I shoot two hundred or
>so pictures at my son's basketball games. After editing and deleting I am
>looking for a program that will rename a large number of files.
>
>thanks
>
>Paul
>
A pretty general request. What criteria do you wish to apply to the
original name to determine the new name?
If the criteria are general (i.e. replace prefix A with prefix B), you
can do that with a pretty simple shell script.
For example: Your original names are of the form P0812xxxx.JPG where
xxxx is an ascending integer sequence monotonically increasing from zero;
this script will replace the "P0812" part with "yosemite_aug12_" where
P08120001.JPG will become yosemite_aug12_0001.JPG.
#!/bin/ksh
#
prefix=${1:-P}
newprefix=${2:-P}
suffix=${3:-.JPG}
for file in ${prefix}*${suffix}
do
mv ${file} ${newprefix}${file##${prefix}}
done
====
chmod +x your script then:
scriptname p101 aug_01_ .jpg
will rename all files starting with p101 and ending with .jpg in the
current working directory to begin with aug_01_.
(e.g. p1010001.jpg becomes aug_01_0001.jpg)
(if you don't have the korn shell installed, change the first
line of the script to #!/bin/bash).
[ Post a follow-up to this message ]
|