[BNM] image renaming
Ali
ali at nubz.com
Mon Jun 25 16:29:04 BST 2007
if you don't have root access and we are talking about a hosted space and the labels are in a database table the following php might help (assuming mysql here):
//select all the text labels from the database and loop through them
$allTextLabels=mysql_query("SELECT * FROM text_labels");
while($textLabel=mysql_fetch_array($allTextLabels)){
$sourceFile="./imagedir/".$textLabel['id'].".jpg";
$newFile="./imagedir/".$textLabel['label'].".jpg";
copy($sourceFile,$newFile);
}
hth
Ali
----- Original Message -----
From: Stephen Ticehurst
To: Brighton New Media
Sent: Monday, June 25, 2007 4:08 PM
Subject: Re: [BNM] image renaming
awk '{ print "mv " $1 ".jpg " $2 }' moo.txt >runme
if your file is a txt file called moo.txt. This will generate a file called runme which you can then run containing the following:
mv 1.jpg abc.jpg
mv 2.jpg def.jpg
mv 3.jpg ghi.jpg
> >
> > Sounds like a job for Python/Perl/Ruby to me.
> >
> > The "safest" way would probably be to write something to convert the
> > table into a series of commands like:
> >
> > mv 1.jpg abc.jpg
> >
> > and dump them to at text file, so at least you can eye-ball it before
> > you attempt to rename every single file and forget something crucial...
> >
> >
> > On 25 Jun 2007, at 14:53, Richard Wells wrote:
> >
> > > I apologise for a basic question but I have a hundred jpegs which are
> > > numbered 1.jpg, 2.jpg, 3.jpg etc and a corresponding table with text
> > > file names:
> > >
> > > 1 abc.jpg
> > > 2 def.jpg
> > > 3 ghi.jpg etc
> > >
> > > Is there an easy way to rename my jpegs with the text names?
> > >
> > > Richard
> > > --
> > >
> > > BNM Subscribe/Unsubscribe: http://www.brightonnewmedia.org/options/
> > > bnmlist
> > >
> > > BNM info/archives:
> > > http://www.brightonnewmedia.org/
> > >
> > > BNM powered by Wessex Networks:
> > > http://www.wessexnetworks.com
> > >
> >
> > --
> >
> > BNM Subscribe/Unsubscribe: http://www.brightonnewmedia.org/options/bnmlist
> >
> > BNM info/archives:
> > http://www.brightonnewmedia.org/
> >
> > BNM powered by Wessex Networks:
> > http://www.wessexnetworks.com
> >
>
>
>
> --
> Kind regards,
> Andy
> _______________________________________
> Andrew Gill
> Binary Portfolio Ltd
> Telephone: 01273 704412
> The Sussex Innovation Centre, Science Park Square, Brighton, BN1 9SB. U.K
> http://www.BinaryPortfolio.com
>
> BinaryPortfolio.com is the trading name of Binary Portfolio Limited. Binary
> Portfolio Ltd, a company registered in England and Wales with the company
> number 06013830 and VAT Number 902522463 and whose registered office is
> MARIA HOUSE, 35 MILLERS ROAD, BRIGHTON, BN1 5NP.
>
> This message may contain information that is privileged or confidential. If
> you are not the intended recipient please delete it and inform the sender
> immediately. Within the bounds of law, the UK based entities in Binary
> Portfolio Ltd retain all emails and IMs and monitor them to ensure
> compliance with their internal policies and for other legitimate business
> purposes.
> --
>
> BNM Subscribe/Unsubscribe: http://www.brightonnewmedia.org/options/bnmlist
>
> BNM info/archives:
> http://www.brightonnewmedia.org/
>
> BNM powered by Wessex Networks:
> http://www.wessexnetworks.com
--
Stephen Ticehurst
sticehurst at jtsr.co.uk http://www.moleville.co.uk/
--
BNM Subscribe/Unsubscribe: http://www.brightonnewmedia.org/options/bnmlist
BNM info/archives:
http://www.brightonnewmedia.org/
BNM powered by Wessex Networks:
http://www.wessexnetworks.com
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.9.6/865 - Release Date: 24/06/2007 08:33
More information about the BNMlist
mailing list. Powered by Wessex Networks