Blog how to import note attachment from Evernote with tags [Linux]
My name is Spleenico and the idea I would like to suggest is to blog an how-to to explain how to import notes from Evernotes together with their tags for direct use with TagSpaces.
I made a script that worked for me and I would like to share it if it can help more people.
I suggest the team to check my code and if they think it is a good idea, to publish it. The code and the explanations can be freely changed and distributed as long as the script header (authorship, GNU General Public License) is maintained.
- My goal was to import a 'file cabinet' notebook (my paperless office: scanned diplomas, invoices) that I currently have in Evernote. So the script imports the note attachments (usually pdf files in this case). Notes in plain text are NOT imported because I simply do not have any.
- this script imports all attachments, add the tags in the file name (Tagspaces format), and makes sure all file names are unique.
- This script should work on Linux computers (in my case, Ubuntu 12.04), with the Windows version of Evernote (currently, 184.108.40.20663) running under Wine (with the PlayOnLinux frontend in my case). Possibly Windows users could run this script using Cygwin or by installing Linux in a virtual machine, but I did not test for this.
- as far as I know this script works as intended, but bash scripting is a hobby, not my work. Please let the code be checked by an expert!
- Example of program actions:
- I have a note "salary statement 2013" with the tags "salary", "2013" and "Work" with 2 pdf files attached to it: "salary1.pdf" and "salary .pdf"
- The pdf files will be imported in the desired location and renamed as: "salary1[salary 2013 Work].pdf" and "salary @2@[salary 2013 Work].pdf". Assume the file "salary1[salary 2013 Work].pdf" already exists in the destination folder, then the file name is changed to "@salary1[salary 2013 Work].pdf" to make it unique.
In your terminal or file explorer:
1. Create a folder where you want to store all your files
2. Create an empty file 'EN2TS.sh' in this folder.
3. Copy the script text into the file
4. For each PDF document, Evernote creates a PNG image that I did not want to import. So the default behavior is to delete these PNG files from the Evernote export folder. If you want to keep these files, delete or comment the line 'rm .png 2> /dev/null' as explained in the script comment.
5. Close and save the file. Make it executable if needed.
In the Evernote (windows) client:
6. Sync your notes
7. Right click on your notebook and select "export notes"
8. Select "export as multiple web pages (html)"
9. Click "Options..." and tick all attributes
10. Click "Export" and select the folder created on step 1
11. Click "Make New folder" to make subfolder into it, which you name 'ENexport' (the name is case sensitive)
In your terminal or file explorer:
12. Execute the script 'EN2TS.sh'
13. Delete the script 'EN2TS.sh' and the Evernote export folder
14. Some of the image files you imported (.gif, *.jpeg) could come from e.g. emails forwarded to Evernote with company logos. Maybe good to check what are legitimate attachments among these image files and what is junk.
# EN2TS.sh by Spleenico firstname.lastname@example.org
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# To read the GNU General Public License, see http://www.gnu.org/licenses/.
for HTML in *.html; do
find the line containing "Tags" in the html file
clean this line from everything but tags (e.g. remove html markup, etc)
cat -e "$HTML" | grep -a Tags | sed -e 's@<tr><td><b>Tags:</b></td><td><i>@@' \
-e 's@</i></td></tr>@@' -e 's@,@@g' -e 's@\(.*\)\^.*@\1@'
if there are any attachments for this note...
if [ -d "$FOLDER" ]; then
*.png files (usually pdf previews generated by Evernote) are deleted.
Remove or comment the line below if you want to import *.png files.
rm *.png 2> /dev/null
for ORIGINAL in *; do
when a folder is empty after removing all .png files, it leaves a '' in the variable $ORIGINAL.
This line prevents errors with cp
if [ ! "$ORIGINAL" = '*' ]; then
replace [ and ] by @ from original file names (would be recognized as a tag otherwise),
before adding tags in new filename
echo "$ORIGINAL" | tr '[' '@' | tr ']' '@' | sed "s@\(.*\)\.\(.*\)@\1[$tag].\2@"
if file name already exists at the destination location,
append ´@'' at the beginning until the new file name is unique
while [ -f ../../"$NEW" ]; do
copy the attachment to the desired location
cp "$ORIGINAL" ../../"$NEW"
Claudius Ellsel commented
Thank you for sharing the script. I do not use Evernote myself, but think that other users willing to migrate might benefit from it.
And one always has to vote for own ideas in uservoice unfortunately :)
I just realize that if an Evernote tag contains a space, eg 'working contract', it will be imported as 2 tags in TagSpaces, 'working' and 'contract'. If my idea is selected I can adapt the script to import the tag as 'working_contract'.
Sorry it is a bit silly to vote for my own idea. I did not do it intentionally... ;)