“my” means that it’s a handler/function defined in the AppleScript, not a one defined in some scripting extension etc
() indicates that makeTempFolder() is call to a function/handler and not a variable. You should be able to find makeTempFolder defined in the AppleScript
thank you very much.
this is the apple script. I have no clue how to enter the path. I tried all kinds of combinations.
I cannot find where makeTempFolder is defined in the AppleScript, now do I know how to define it.
on export()
tell application id "com.evernote.Evernote"
set _folderPath to my makeTempFolder()
set _notebooks to notebooks
repeat with _notebook in _notebooks
set _notes to notes of _notebook
if (count of _notes) > 0 then
-- assumes notebook's name is a valid filename and not the same as another notebook's
set _path to _folderPath & "/" & name of _notebook & ".enex"
with timeout of 2 * 60 * 60 seconds
export _notes to POSIX file _path format ENEX with tags
end timeout
end if
end repeat
end tell
do shell script "open " & _folderPath's quoted form
end export
on makeTempFolder()
-- errAEPrivilegeError if inside of "tell"
do shell script "mktemp -d -t 'EFEvernoteExport'"
end makeTempFolder
my export()
Just to build on the explanations by @jemostrom with an example, you can see the path being created and set to the variable if you do a simple test like this to see the content of the _folderPath variable:
Each time you run it, you should get a new path. You can read about the mktemp shell command being run here:
If you really wanted to use a common path of your own as above, you could skip the creation of a temporary folder and set it directly to the variable.
You have missed a space after “dialog”, and it isn’t creating a folder like the ten folder creation shell command, it’s setting a variable to the output folder path. That would need to exist.
Also note most of your code is in export but in the example above you have moved some outside it, so you’ll be getting two temp folders with what you have and you are displaying the one Evernote is not using.
You look to be combining previous points in an unusual way and with incorrect syntax, so let’s take a step back and see if we can get you back on track.
What are you ultimately trying to do here?
Run the original script that utilise a temporary folder.
Run a modified script with the folder set to /Users/cyrus/Downloads.
Run a modified script with the folder set to some other path that already exists.
I want to convert my evernote notes to EagleFiler.
There is a script to do so both recommended by the developer and on the developer’s site.
Here is the script.
If I follow your approach, you are right, I am making contorted amateur attempts at solving a problem without having described the problem.
. the script seems to run flawlessly sorting through and exporting evernote notebooks and notes (I see it on the evernote activity window)
, at the end the script crashes with the error message below. I think that the crash is at the stage of the temp folder creation because it happens at the end, the error message mentions file or directory and I am unable to find a EFEvernoteExport folder in my Mac after the script runs.
So you are right, my questions represent my amateur attempts at troubleshooting the problem. I should have described the problem in the first place
Right, let’s take a simplified approach with a script based on the script you shared originally.
set EXISTING_OUTPUT_DIR to "~/Desktop/EN_out/"
set MAX_SIZE to 20
tell application "Evernote Legacy"
set _notebooks to notebooks
repeat with _notebook in _notebooks
set _notes to notes of _notebook
if ((count of _notes) ≤ MAX_SIZE) and ((count of _notes) > 0) then
set _path to EXISTING_OUTPUT_DIR & name of _notebook & ".enex"
with timeout of 2 * 60 * 60 seconds
export _notes to POSIX file _path format ENEX with tags
end timeout
end if
end repeat
end tell
Important Points
I’ve replaced the whole temporary directory business with just a directory on the desktop called EN_out. You should create this directory prior to running the script. Keep it open in Finder and see it being populated as the script runs.
I don’t see much if any point here for using a temporary directory solution as you need to grab the contents anyway, and there was no clean-up afterwards.
For testing purposes as I have a lot of Evernote notebooks, most with lots of notes, I set a variable MAX_SIZE so that I only exported small notebooks.
It made my testing much quicker!
My advice would be to start with this set to a lower value to test it works and then increase it to something much larger when you want to run a full export.
This one may be important to you or it may not. The current latest Event client app on Mac does not support AppleScript. You have to use the special legacy Evernote app if you have updated. You can have them alongside one another. If you are running an updated Evernote app, install the legacy app and you can keep the script as is. If you are still on the old client that supports AppleScript, change "Evernote Legacy" to just be "Evernote".
please note that the script seem to work extremely well before the crash. The folder was being progressively populated.
what does MAX_SIZE refer to? number of notes ? size in MB? If I want to take out the MAX SIZE and zero count checks, how should I edit the script ?
Should I simply take this out ?
if ((count of _notes) ≤ MAX_SIZE) and ((count of _notes) > 0) then
set _path to EXISTING_OUTPUT_DIR & name of _notebook & ".enex"
with timeout of 2 * 60 * 60 seconds
For the notebook it gets to and fails on, any chance it is named named something that might be interpreted as a different file path? E.g. If it contained a forward slash.
Number of notes.
Don’t remove anything just follow my instructions and change it to a larger number. E.g. 999999
What you suggested would be insufficient in one respectand remove essential code too!
Evernote (web version ie not app store)
Version 7.14 (458244 Direct)
Editor: 69.3.10951 (15add1e)
I am reviewing the notebook names one by one. I already found names with “/” “,” and “→ ”
I will rerun the script after cleaning up the 500 notebook names.