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: has <email@hidden>
- Date: Fri, 7 Sep 2001 11:18:13 +0100
Yet another possible solution: this one uses both RegEx Commands and Akua
Sweets OSAXen (because I'm lazy that way). This goes through a selected
folder, processing each file that has a .jpg extension. It looks up each
file's code in your conversion list; if it finds a matching entry it makes
a duplicate to a separate folder and changes the name of the original.
For the OSAXen:
http://www.lazerware.com/software.html
http://www.akua.com/
set foldertoconvert to choose folder with prompt "choose folder containing
the files to convert"
set conversionfile to choose file with prompt "choose file containing
filename info"
set copiesfolder to (choose folder with prompt "choose folder to put the
copies in") as text
--read the conversion list
open for access conversionfile
read conversionfile from 1
set conversioninfo to result
close access conversionfile
tell application "Finder"
--get all files to be processed
set everyfile to every file of foldertoconvert whose name ends with ".jpg"
repeat with eachfile in everyfile
--get file's name, without .suffix
name of eachfile
(items 1 thru -5 of result) as text
--look it up in the conversion list
--(I've used comma-space for delimiter below; replace with \\t if
it's a TAB delimiter)
set thisfilesinfo to REMatch conversioninfo pattern (result & ",
(.+)") using "p\\1a.jpg p\\1s.jpg"
if thisfilesinfo "" then
--make a copy (it may be quicker with AkSw, but I'm not really
sure)
AkuaCopy eachfile to (copiesfolder & word 2 of thisfilesinfo)
with faster operation
--change name of original
set name of eachfile to word 1 of thisfilesinfo
else
beep --didn't find this file in the conversion list
end if
end repeat
end tell
Bear in mind that the MacOS doesn't usually like huge numbers of files in a
single folder (max 500 items?), so you probably shouldn't try to do the
full 3000+ in a single go. This is why I've made the script work 'by file'
rather than 'by list', btw.
has