I was wondering if a script could be created that would save all files in the frontmost open folder or selected files with specific application-specific options.
Here’s what I’m trying to do:
I’m trying to back up my mail into a PC-readable format. I have everything ready to go, except for one problem; the PC doesn’t understand the Mac line breaks, so all mail messages appear very different than when they were received. This can be fixed by using BBEdit’s ability to save with “DOS Line Breaks”. I have 5500 messages that need to be edited in this way, and obviously it would take more time than I have to invest to convert them by hand. Unfortunately, I do not have any experience with Applescript, and do not have the time to learn it as this is taking place at work but for personal reasons. Could anyone help, or at least point me to a website or reference from which I could base a script? I would certainly appreciate it.
tell application "Finder" to set listOfDocs to every item of (choose folder)
repeat with theDoc in listOfDocs
tell application "BBEdit"
open theDoc
set line breaks of document 1 to DOS
close document 1 saving yes
end tell
end repeat
Put all your mail messages in a folder then run this script and choose the folder that they are in.
The Applescript seems to think that “DOS” is an undefined variable; when I quote it, it then tells me that “breaks” is an undefined variable. If I then quote “breaks” (set “line breaks” of document 1 to “DOS”) I get an error: “Can’t set document 1 to DOS.”
I tried using “Record” in Script Editor, but either I was using it wrong or it didn’t work properly, as nothing showed in the text window.
It may help you to know that I am running OSX 10.1.5, running BBEdit through the Classic interface. I don’t know if it makes a difference, but I’ll try booting into OS9.2 and see if that helps.