Browsing: Command Line

Use the power of your Terminal in 2021. Here is a list of our favorite resources.

If you have wondered what you can do with your terminal, the answer is “almost everything”. Here is a list of our favorite resouces for getting the most out of the command line.

{ Comments are closed }

Using Hazel to automatically convert an epub to mobi with Calibre.

HazelSometimes I want to convert a few ebooks from epub to mobi for reading on my kindle. I could add them, convert them, and email them to Amazon using Calibre, but wouldn’t it be cooler to just drop the epubs in a directory and not think about them anymore until you open your kindle to read. This can be done with a workflow I found on (r.i.p.) 7 years ago and it still works today. Using the command line tools embedded in Calbre, a “fire & forget” solution can be created for ebook conversion. The tool can be found here: /Applications/ and to use it with Hazel, follow these steps.

1. Create three directories, ebook, converted, and sent.

2. In Hazel, create the following rule for the directory ebook.

If all of the following conditions are met:

Extension is: epub

Do the following to the matched file:

Run Shell Script:

ORIG_FILE=$(basename "$FULL_PATH")
/Applications/ "$ORIG_FILE" "converted/$(basename "$FULL_PATH" .epub).mobi

Move to folder: converted

3. Now for the directory, converted, add this rule in Hazel.

If all of the following conditions are met:

Extension is: mobi

Do the following to the matched file:

Run AppleScript:

tell application "Mail"
	set newMessage to make new outgoing message with properties {subject:"Hazel to Kindle", content:""}
	tell newMessage
		set sender to "[your email address]"
		make new to recipient at end of to recipients with properties {address:"[your kindle email address]"}
		make new attachment with properties {file name:theFile} at after the last paragraph
	end tell
	delay 30
	send newMessage
end tell

Move to folder: Sent

4. Now just drop your epubs into the directory conver and watch the magic happen.

{ Comments are closed }

TextExpander snippet for youtube-dl to download the audio from a video and save as mp3

For those times when you don’t need the video and just want to listen to the audio later, add this snippet to your toolbox. To use, copy the URL to your clipboard, then expand the snippet in your command line. Prerequisites: Homebrew, youtube-dl, and ffmpeg.

youtube-dl -f bestaudio [clipboard] --exec "ffmpeg -i {} -codec:a libmp3lame -qscale:a 0 {}.mp3 && rm {} "

{ Comments are closed }