Re: file renaming

From: Scott Lurndal (scott_at_slp53.sl.home)
Date: 10/27/04


Date: Wed, 27 Oct 2004 16:03:45 GMT

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).



Relevant Pages

  • Re: Renaming computer and Account in Windows 2000
    ... reg merge from a netware login script before they join AD... ... here so any ideas how I just add the prefix to the existing name.. ... As soon as you rename it and reboot it, ... > the network completely unless you've got your DNS and/or WINS set up to cope ...
    (microsoft.public.win2000.setup_deployment)
  • Re: Script to Rename Computer Name in Domain
    ... i looking a script to rename computer name in domain server 2003 ... To rename a computer you bind to the parent OU/Container of the computer ... you would need to also prompt for the current name. ... ' Bind to the parent OU/container of computer object. ...
    (microsoft.public.windows.server.scripting)
  • Re: Rename File Using Strring Found in File?
    ... OK, thanks, but the script does not seem to rename the files. ... # sleep 1; ... to the string in this particular file that I want to match. ...
    (comp.lang.perl.misc)
  • Re: rename a local group in windows 2003
    ... strComputer = objShell.ExpandEnvironmentStrings ... I tried to rename several local groups using the MoveHere method ... Didn't matter if I ran the script on the ... WinNT provider only rename domain groups, ...
    (microsoft.public.windows.server.scripting)
  • Re: Script to Rename Computer Name in Domain
    ... To rename a computer you bind to the parent OU/Container of the ... the local computer, you must run a script ... you can prompt for the new name with an InputBox ... ' Bind to the local computer object. ...
    (microsoft.public.windows.server.scripting)