Script speed [Was list number]
Script speed [Was list number]
- Subject: Script speed [Was list number]
- From: "Steve Suranie" <email@hidden>
- Date: Tue, 25 Feb 2003 15:20:13 -0500
- Thread-topic: applescript-users digest, Vol 3 #1378 - 14 msgs
Thanks has as usual after I sent the message I sat down and worked it out myself and it was very close to the solution you sent. Here's two other problems I am trying to solve.
I have some scripts which automate our process of getting files into a Cumulus database and making them selectable from a browser in pdf and jpg format. Everything works but since I launched the scripts 5 weeks ago I already have 6,000 + files in a folder named "pdfs" and another 6000+ in a folder named "jpgs".
Because of the process the pdf files are moved into the pdf folder without an extension and the jpgs are saved as "filename copy.jpg". I have a sorter/cleaner script which goes through these two folders and corrects the file names so they end up being filename.jpg or filename.pdf. It looks for duplicates and, once again because of our process, moves the older file to the trash and renames the newer one or if there are no duplicates just renames the file. But it takes so long for this process to work.
Our naming convention is as such: AA022403_001.jpg/pdf
AA is a magazine code
022403 is the date (US style)
the last digets are ad codes
When I archive material I am basically taking all the ads from an issue of the magazine, converting them from pdf format (we go to print with pdf files) to jpg in PS (6.1) and then renaming them so they can all be accessed through HTML pages and Cumulus Web Publisher.
Here's the script I'm using. I thought it would speed the process up by isolating the files from the issue I am working on instead of trolling through the whole folder. For the jpgs I know these are the correct files I need to rename because they'll begin with a 2 letter mag code that matches the same code in a folder hierarchy from where the file came from and will end with " copy.jpg", for the pdfs they are files without the .pdf extension and also have matching mag code. OK, the makes sense to me hopefully it will to everyone else.
Here's the script:[just the jpg portion, the pdf one is similar]
copy (name of every item of theJPGPath whose name starts with thisMag and name ends with "copy.jpg") to jpgFilesList
repeat with i from 1 to count of every text item of jpgFilesList
set thisFile to text item i of jpgFilesList
set thisFilePath to (theJPGPath as string) & thisFile as alias
duplicate file thisFilePath to theFolderPath with replacing
set fileLength to length of thisFile
set fileName to text 1 thru (fileLength - 9) of thisFile & ".jpg"
if the file fileName of theJPGPath exists then
set theoldFilePath to (theJPGPath as string) & fileName as alias
tell application "Finder"
move theoldFilePath to trash
set name of thisFilePath to fileName
end tell
else
tell application "Finder"
set name of thisFilePath to fileName
end tell
end if
end repeat
Like I said, I thought this would be faster but it just chugs along slow as molasses. Any tips, hints, tricks, advice, clues, admonishments, etc. etc. will be happily accepted.
Thanks
Steve
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.