file renaming
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Red Hat support > Red Hat Topics > file renaming




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    file renaming  
paul


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-27-04 12:45 PM

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


----== Posted via webservertalk.com - Unlimited-Uncensored-Secure Usenet New
s==----
http://www.webservertalk.com The #1 Newsgroup Service in the World! >100,000
 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---





[ Post a follow-up to this message ]



    Re: file renaming  
Scott Lurndal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Re: file renaming  
Paul Lutus


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
10-27-04 10:45 PM

paul wrote:

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

You don't say how you want to rename them, and you don't say what kind of
files they are. Here is the basic idea:

#!/bin/sh

# enter the correct suffix below

suffix=jpg

n=0
for fn in *
do
mv $fn $n.$suffix
((n++))
done

--
Paul Lutus
http://www.arachnoid.com






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:23 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register