Marc's Place


 

Stacks Image 6


Scripts for Applescript, ASP, JS, a.o.

Send E-Mail to Markdown AppleScript
Stacks Image 57
Stacks Image 59
Now that Evernote dropped AppleScript support completely (in 2020) and are 'thinking about it', and changing their editor at will, it's time to switch from Evernote to something else. I tried Apple Notes, and many others and ended up with Joplin. Turns out I was not the only one switching, and the Joplin-team worked very hard the last months (2020-2021) to make Joplin a worthy Evernote replacement. Thumbs up!

So, to now move my emails from Apple Mail into Joplin, there are two ways:
  • Copy the email header, paste into Joplin's WYSIWYG editor, followed by a copy/paste of the rest of the email, or
  • Rewrite my version of the 'Apple Mall to Evernote'-script, to an 'Apple Mail to Markdown'-script.

I choose the latter.
The script here strips the email of all HTML and attachments, so you're only left with text and a nice header with email details.


A screenshot of how an email in Joplin looks when my modified version of the script has done its job:
Stacks Image 61
Follow my blog-posts for any updates on this script. Feel free to improve it, and please let me know if you have.

Download zip

Buy me a coffee-1

Import E-Mail into Joplin


Go into Apple Mail, select one or more emails and choose the 'Send E-Mail to Markdown'-script from the AppleScript menu.
This will create a folder named mail_md_export inside your Downloads-folder, and in there you'll find your exported e-mails. Use Joplin's import 'MD - Markdown (File)' to import one file at a time, or 'MD - Markdown (Folder)' to import the 'mail_md_export'-folder and distribute your emails to other notes from there.


Installation


To install the script, open the User Scripts Folder ~/Library/Scripts/ or use the AppleScript menu to open the User Scripts folder:
Stacks Image 65
If you do not see the AppleScript Menu icon in your menu bar, you can enable it in Script Editor’s General preferences:
Stacks Image 69
Send E-Mail to Evernote AppleScript
 Evernote
A while ago, I was looking for a way to shrink my list of mailboxes and the 1000s of mails therein. I have used MailSteward Pro to backup my emails to a remote MySQL server for a long time, in case everything gets lost at Apple's iCloud. Which isn't very likely, so I started looking for another way to archive old emails and still have the same easy access with all search capabilities. This where Evernote comes in! With Evernote I can search on anything, even text in PDFs and images.


Googling a bit I found this AppleScript: Apple Mail to Evernote. The script works nearly perfect and I added and changed some code to get the date/time in the title of the note and some other things, see the version history below.

A screenshot of how an email in Evernote looks when my modified version of the script has done its job:

Screen Shot 2014-05-15 at 10.49.19

Follow my blog-posts for any updates on this script.

Download zip

Buy me a coffee-1

To install the script, open the User Scripts Folder ~/Library/Scripts/ or use the AppleScript menu to open the User Scripts folder:

Screen Shot 2016-05-31 at 19.08.03
and simply move the script into this folder and you will see the script listed under the AppleScript Menu.
If you do not see the AppleScript Menu icon in your menu bar, you can enable it in Script Editor’s General preferences:

Screen Shot 2016-05-31 at 19.12.54

Import E-Mail into Evernote


Go into Apple Mail, select one or more emails and choose the 'Send E-Mail to Evernote'-script from the AppleScript menu.
Check the chosen Evernote notebook if your selected emails are in there, and if so, you can delete the original messages.

Note : Some encoded message-content seems impossible to convert, and the script would crash. What I did is that the note in Evernote is created, with the nice header and all attachments, but with the encoded message text.
What you then have to do is to go into Apple Mail or Microsoft Outlook and copy the email text, go back to Evernote and delete the encoded text and then paste the message text into the note.

Thanks to Veritrope for the basis of this very useful script!


Download zip

Buy me a coffee-1

    Version history
v2.08 05-2014 Added date and time in front of the subject-title so when sorted alphabetically in Evernote, the emails are listed by date/time.
v2.09 07-2014 Fixed HTML parse bug in htmlFix where the check on ; chrashed the script when there was   or equiv. in the string.
v2.1 07-2014 Fixed time display in the note's title when adding multiple emails. All but the last note's time in the title would be converted to, for example 14:05, 1=4=0=5. Look for replace_chars.
v2.2 08-2014 Added a dialog at the end so you know when the process has finished.
v2.3 08-2014 Encountered an email without a content-type header. In that case I set myHeaders to 'text/plain'.
v2.4 01-2019 Added code to remove from HTML e-mails, because this often breaks the import into Evernote. If you do not want this, comment the 'removeBetween' function call.
v2.5 02-2019 Removed Growl support and modal dialog messages, and replaced those with standard mac OS Notifications.
Save and Restore Apple Finder Windows scripts
 finder
Since Apple released Mavericks (10.9), the Finder doesn't save and restore its open windows, and the tabs inside these windows. I find this a real nuisance and it wonders me why Apple haven't been able to fix this. I tried writing 'defaults' settings, with no effect.

Anyway, then I decided to write my own solution, in AppleScript. After googling a few hours on how to do things in AppleScript, I came up with two scripts:

The 'Save Finder Windows'-script


This script saves the current open windows, their positions and sizes, including the tabs inside these windows ... into a text file! This text file can be edited and modified in Sublime or TextWrangler. You can also sync it to another Mac!

The text file is stored in your Preferences folder :

/Users/yourname/Library/Preferences/windowtabs.txt

Its contents look like this:

$0$23$1279$1440
Macintosh HD:Users:yourname:Dropbox:Projects:
Macintosh HD:Users:yourname:OneDrive - SDS82:Projecten:
Macintosh HD:Users:yourname:Downloads:
Macintosh HD:Users:yourname:Sites:begeleider:
Macintosh HD:Users:yourname:Sites:marc.vos:
$1281$23$2560$1440
Data HD:_Foto (nog doen):Scansessie dia's van onszelf:Megabox:02:
Macintosh HD:Users:yourname:Pictures:~ Foto archief:


Lines that start with a $-sign are Finder Windows coordinates, separated by $-signs.
Lines that follow a Finder Window definition, are paths that are made into tabs inside that Finder Window.

You see that you can modify this TXT-file yourself and add or remove windows and paths (tabs).

The 'Restore Finder Windows'-script


This script reads the text file, creates the windows at their saved positions with their saved sizes and reopens, inside these windows, the saved paths as tabs.

How to execute the scripts


Of course you can execute scripts at any moment you like. The text file will be overwritten, with each execution of the 'Save Finder Windows'-script.
I added both these scripts to the Scripting Menu. But you can also add them to the Finder's toolbar or just place them on the desktop or ... or ...

20160608.Save and Restore Finder Windows

Download


The ZIP contains the editable scripts and the compiled versions.

Download zip

Buy me a coffee-1
AppleScript to create a new folder inside current or selected folder
 finder
Here's an AppleScript with which one can create a new folder inside a current or selected folder, or inside a current window or inside a folder containing a selected item.

Code

tell application "Finder"
set theList to selection
if theList is {} then
-- Nothing selected
set x to (folder of the front window)
else
-- Only the first item is significant
set x to item 1 of theList
end if

-- Check for file selection
set theClass to class of x
if theClass is not folder then
set x to (container of x)
set theClass to class of x
end if

-- Create new folder inside selected folder
if theClass is folder then
set theFolder to x as string
--display dialog theFolder
try
set theName to text returned of (display dialog ¬
"Create folder named:" default answer "Untitled")
set y to make new folder at theFolder with properties {name:theName}
on error
-- display dialog "Nothing happened"
end try
end if
end tell

Implementation


Compile and export it as an application, then drag it onto a Finder-window's toolbar:

Screen Shot 2016-07-01 at 11.34.22

Then, wherever you need a new folder, simply select something in the finder and click on New Folder:

Screen Shot 2016-07-01 at 11.40.14
 
Buy me a coffee-1
JavaScripts

In this download, you will find three conversion scripts:
  • Celsius to/from Fahrenheit
  • The leapyear test
  • Conversion between number systems (dec to bin/hex/oct/surprise)
and set, consisting of a login script and a user-maintenance script, which uses a generated hash table to check against entered username/password, on the client's computer - no check on a server involved.


Download
Subversion start-up script

The download contains a Subversion StartupItem for OS X that will start svnserve with option -d so it runs as a standalone deamon. Just unzip and double-click the package file.


Download    
TN5250j Startup script

Here's an AppleScript to start the TN5250j Terminal Emulator with multiple sessions in one window. You can add this icon to the dock between your other applications.


Download    
AppleScripts for Tex-Edit Plus

Here you can download some handy AppleScripts for Trans-Tex' Tex Edit Plus.
  • Mac -> PreHTML : Inserts the page structure and surrunds the original content with <pre></pre>.
  • Mac -> ISO-set : Translates some special characters to HTML entities.
  • Make <SELECT> pop-up menu : creates a pop-menu wth an onChange event from the original content.



Download      
Keep track of your kilometerage
My learning project for Active Server Pages : a webpage to register the kilometers you drive for private or business use and the costs for your car(s). You can register an unlimited number of cars. An empty Access-database is included.


Download    
buy me something-2
© 1997- Marc Vos (and others)   -   Privacy Statement   -    Contact Me

On this website, Google Analytics is used to track visitor statistics. These are anonymised data about the number of visitors, which pages they visit on this site, from which regions they visit, which web browsers they use, etc.. You will also see non-personalised ads via Google AdSense. Cookies from Paddle or Paypal are placed when you click on a 'Buy now!' or 'Donate!' button, and possible cookies from Disqus when you use that system to comment on one or more blogposts.
Privacy Statement