Re: Read Text File to Rename Images - Please help!
Re: Read Text File to Rename Images - Please help!
- Subject: Re: Read Text File to Rename Images - Please help!
- From: email@hidden
- Date: Wed, 5 Sep 2001 23:00:44 EDT
Ray,
Flat text file pseudodatabases are my subspecialty!
Here's a script which will get you started (it might even get you finished).
I'm not sure I fully understand the part about duplicating the file and the
fullsize/thumbnail:a/s issue. Will you be doing some post-processing to
convert one copy to a thumbnail? Or are there already thumbnails which need
renaming too? This script assumes there is only one version of each picture
to start.
-- change this to whatever makes sense on your system
set basePath to "WorkZone:sku2ebu:"
set flatfile to basePath & "flatfile"
set x to read file flatfile
-- convert the flat data into a list of paired elements
set xlist to my powersplit(x, {return, ","})
repeat with aPair in xlist
if aPair as string is not equal to "" then
set origFile to basePath & (item 1 of aPair) & ".jpg"
set newName to "p" & ((item 2 of aPair) & "a.jpg")
set newFile to basePath & "p" & ((item 2 of aPair) & "a.jpg")
set duplicateName to "p" & ((item 2 of aPair) & "s.jpg")
tell application "Finder"
set name of file origFile to newName
set dup to duplicate file newFile
set name of dup to duplicateName
end tell
end if
end repeat
on powersplit(src, delimList)
set newDelim to (item 1 of delimList) as string
if length of delimList is equal to 1 then
set srcAsList to {}
try
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to newDelim
set srcAsList to (text items of src) as list
set AppleScript's text item delimiters to oldDelims
on error
try
set AppleScript's text item delimiters to oldDelims
on error
set AppleScript's text item delimiters to {""}
end try
end try
return srcAsList
else
set linesAsList to {}
set srcAsList to my powersplit(src, newDelim)
repeat with aLine in srcAsList
set aLineAsList to my powersplit(aLine, (rest of delimList))
copy aLineAsList to end of linesAsList
end repeat
return linesAsList
end if
end powersplit
Good luck.
cc please, on digest
Jeff Baumann
email@hidden
www.linkedresources.com
In a message dated 9/5/01 6:37:46 PM, Ray Barber wrote:
>
Hello All ...
>
>
I have just learned tonight I will have to rename *all* of the original web
>
files on our server, from our current part number (SKU) to another number
>
(EBU #) for our new e-commerce system. Of this, there are close to 3,269
>
give or take a few jpgs. Some will have to be re-shot.
>
>
What I need help with is a script that can read a flat text file, with two
>
numbers (comma delimited most likely), and change the actual name of a JPG
>
file from our old part number to the new EBU number.
>
>
Sooo ... In the flat text file, it would have something like this -
>
>
10-10203, 123455
>
xx-xxxxx, xxxxxx
>
xxx-xx-xxx, xxxxxx
>
>
... and so on ...
>
>
These numbers are not random, they are associated to the list that is run
>
from a HP server. The first number you see is our old number, with the
>
second our new EBU number.
>
>
As an example, the original jpgs look like this; '10-10203.jpg' and would
>
need to change to 'p12345a.jpg', etc. Also, I need to duplicate the newly
>
named file, and give it to 'p12345s.jpg'. The starting p, a and s are
>
important, as they represent part of the EBU # - plus represent a large
>
image and a thumbnail image.
>
>
We go 'live' on the 15th of October, but I have to finish my work two weeks
>
prior to the 15th.
>
>
Ideas?? I rarely post on the list but my time just got squished to nill -
>
thanks so much to anyone who can get my butt out of a jam.
>
>
Ray