Jump to content
dpnote

How-To: Batch file script to backup Evernote to Google Drive

Recommended Posts

I wrote this simple Windows batch file script that you can use to backup all your Evernote notebooks to Google Drive. You can also use Windows' Task Scheduler to schedule the backup as needed. The CMD file is attached.

  • The variable ProgPath specifies the full path of the ENScript.exe file.
  • The Variable BackupFolder sets the backup folder by using Google Drive File Stream.

 

@echo off

@rem Use Unicode/65001 code page to support notebooks with non-English locale names
chcp 65001 > nul

@rem Make sure the Evernote script file is in the right path.
set ProgPath="%LocalAppData%\Apps\Evernote\Evernote\ENScript.exe"
if Not Exist %ProgPath% echo Error: Cannot find %ProgPath% program file. Exiting. & goto :EOF

@rem Build the timestamp to be used for the backup file name
for /F %%A In ('WMIC OS GET LocalDateTime ^| Findstr \.') Do @Set B=%%A
set Timestamp=%B:~0,8%-%B:~8,6%
@rem echo Timestamp=%Timestamp%

@rem Specify the backup folder using the generated timestamp
set BackupFolder=G:\My Drive\EvernoteBackups\%Timestamp%
@echo Backup Folder = "%BackupFolder%"
if Not Exist "%BackupFolder%." Mkdir "%BackupFolder%"

@rem For each Evernote notebook, call the subroutine to back it up.
for /F "delims==" %%i In ('%ProgPath% listNotebooks') Do Call :BackupNotebook "%%i"
@echo Done
Goto :EOF

@rem Subroutine to backup Evernote notebooks
:BackupNotebook
set NotebookName=%~1
@echo Backing up notebook %NotebookName% ...
%ProgPath% exportNotes /q "notebook:\"%NotebookName%\"" /f "%BackupFolder%\%NotebookName%.enex"
exit /b

 

BackupEvernote.cmd

  • Like 1

Share this post


Link to post

 

On 5/1/2020 at 3:44 AM, dpnote said:

I wrote this simple Windows batch file script that you can use to backup all your Evernote notebooks to Google Drive. You can also use Windows' Task Scheduler to schedule the backup as needed. The CMD file is attached.

Is this tool meant to retain the timestamps of the notes once they're converted to Docs? That's my problem with exporting to HTML and manually uploading to GDrive; the metadata is not retained in the export, so the creation and modified dates are all uniform.

Share this post


Link to post
14 minutes ago, zigzagwanderer said:

Is this tool meant to retain the timestamps of the notes once they're converted to Docs? That's my problem with exporting to HTML and manually uploading to GDrive; the metadata is not retained in the export, so the creation and modified dates are all uniform.

This is a script to export to .enex format
There is no .html option, and no conversion to "Docs"

Share this post


Link to post

Just my opinion,  but an export to anything other than ENEX (which is already baked into Evernote) is hardly a 'backup' since it can't be imported back to replace the original note.  It's just another copy of the database in another format.  Your choice,  but if the Apocalypse ever happens I'd bet there will be multiple options to export your database / import to another app at the time...

  • Like 1

Share this post


Link to post
47 minutes ago, gazumped said:

since it can't be imported back to replace the original note

About that "replace the original note"
Importing a .enex file does not replace the original note - it creates a new note; losing Note-Id and Notebook

  • Like 2

Share this post


Link to post

Fair point - I should have said provide a carbon copy or something;  the point being that a re-saved document is not going to look exactly the same as the original,  and if you wanted to re 'import' a notebook from Google a great deal of work would be involved.  Enex files for all their limitations (and there are a few...) are good enough for me at the moment.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...