jdberry/tag: A command line tool to do tags on Mac files.
I don’t use tags much, mainly to quickly mark a set of files going down a list with quicklook. I’ve now got an applescript that will simply tag the selection in the finder blue. Keyboard shortcut via FastScripts.
Tag: applescript
• The FastScripts menu can now be presented by keyboard shortcut even if the menu bar icon is not visible
This is nice, I can keyboard the menu then see the shortcuts I’ve forgotten.
he Apple Script lets you select a group of photos in Photos. If one (and only one) photo got location data the location data is shared with the other photos in the selection.
Used to be a copy paste job with iPhoto.
Printing Multiple Notes
As I’ve mentioned before we use Apple Notes a lot in our class. If the class are writing, unless there is a need for formatting or layout, I often ask the pupils just to stick to notes.
Notes are easily AirDropped to me when I need to collect work and both pupils and myself can organise them in a fairly simple manner.
Occasionally I want to print the pupils work. Notes, reasonably enough, only lets you to print one note at a time. I wondered if there was AppleScript that would help. I found Export Apple Notes via AppleScript which exported a folder of notes to a new TextEdit document. I altered it to:
- Allow you to choose a folder from Notes.
- Export to an html file on disk.
- Provided page breaks so that the notes would each print on their own page.
Not particularly pretty, I guess I could work on the styles a little.
You need to be in my lucky position of having a mac in your classroom. Mine uses the same account as my iPad which helps me organise thing a lot.
Here is the code, I suspect it could be improved. Even if you don’t use AppleScript is easy enough to run. Open the AppleScript editor, create a new script, paste the code below in and hit run. You will be asked to choose a folder and then name an html file. The file will be created and opened with your default browser.
You then can print.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set htmltop to "<!doctype html> | |
<html lang=\"en\"> | |
<head> | |
<meta charset=\"utf-8\"> | |
<title>Notes Export</title> | |
<style> | |
@media print { | |
hr { | |
page-break-after: always; | |
} | |
} | |
</style> | |
</head> | |
<body>" | |
set htmlbottom to "</body> | |
</html>" | |
tell application "Notes" | |
activate | |
set x to (name of every folder whose name is not "Notes") | |
set foldertoexport to (choose from list x) as string | |
if folder foldertoexport exists then | |
set output to "" | |
repeat with aNote in notes in folder foldertoexport | |
set noteText to "<!– ### Start Note ### –> | |
" | |
set noteText to noteText & ("<h1>" & name of aNote as string) & "</h1> | |
" | |
— set noteText to noteText & ("<p>Creation Date: " & creation date of aNote as string) & "</p>" | |
— set noteText to noteText & ("<p>Modification Date: " & modification date of aNote as string) & "</p>" | |
set noteText to (noteText & body of aNote as string) & "<hr> | |
" | |
set output to output & noteText | |
end repeat | |
set thehtml to htmltop & output & htmlbottom | |
set theNewFile to choose file name default name foldertoexport & "-notes.html" | |
set myFile to open for access theNewFile with write permission | |
write thehtml to myFile as «class utf8» | |
close access myFile | |
else | |
display dialog "not likly to happen" | |
end if | |
end tell | |
tell application "Finder" to open theNewFile | |
Downloading Media from WordPress using AppleScript
I got a request from a teacher who wanted to download a years worth of images from a Glow Blog (for end of year slideshow).
Although there are plugins that can do this these are not available on Glow Blogs. I was stumped apart from going through the site and downloading them 1 by 1. But after a wee bit of thinking I though I’d try using the REST API via AppleScript.
The REST API will list in JSON format the media:
http://johnjohnston.info/blog/wp-json/wp/v2/media/
Look at that in FireFox for a pretty view.
JSON Helper is
an agent (or scriptable background application) which allows you to do useful things with JSON directly from AppleScript.
So I can grab the list of media from a site in JSON format use appleScript to download all the files.
The script I wrote is not great, you can’t download from a particular year, but a quick look at the JSON will help in working out how many files to download.
I am sure there are more efficient ways to do this and I’ve only tested on a couple of site, but it seems to do the trick and might be useful again sometime.
Figured out how to automate posting of old AudioBoos with AppleScript, test here more to come then #Edutalk.
Exiting audioboo(m) part 1
AudioBoom is closing its free tier:
If you take no action, then after 2nd October 2017, you will no longer be able to upload new content and your account will become private. We will continue to enable distribution of your existing content for a period of a month so all your RSS feeds and web embeds will continue to work for that period. If you choose to move to another podcast provider, let us know by emailing us at support@audioboom.com and we will redirect your RSS feeds for you. We’ll need at least 5 working days to comply with your request. After 36 months from 30th August 2017, your account will be deleted (including your old podcasts and your RSS feeds, so we recommend that you arrange for redirection of your RSS feeds, download your old podcasts and back them up elsewhere, before that period expires.
from: Subscription Changes
Which is depressing news for me and for Edutalk. I have 50 odd boos which range over field recording, audio recorded for Edutalk and some microcast type posts. Edutalk has had several hundred contributions from many different people over the years.
The situation at Edutalk is more worrying. I could pay $9.99 a month to keep my own account alive. But Edutalk has had contributions from many different people, we could not expect them to pay up for the privilege of having their content syndicated onto Edutalk.
AudioBoom did not provide any export that would help with importing into WordPress (or anything else). This differs from the posterous closedown which did give a WordPress export option.
We do have a while to sort this out. There is a month until the accounts become private.
AudioBoom does have an API, and we used it before.
I am not intending to rush, so this is the plan.
- Download the information about the posts using the API
- Download all the mp3s by parsing the JSON the api provides.
- Delete all the posts on edutalk that have been syndicated from AudioBoom.
- Upload all the mp3s
- Create posts that embed all these mp3s with the matching titles and descriptions etc.
Today I managed to download the json files and the mp3 I used AppleScript as I find it easier to get stuff done with that than pure shell scripting.
Thank goodness for the JSON helper for AppleScript which worked a treat.
I’ve put the script here:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set downloadfolder to "/Users/john/Desktop/audioboom/edutalk/" | |
–so this next bit could be a loop but doing it manual was not much of a hassle | |
set pagecount to 9 | |
set tag to "edutalk" | |
set itemcount to 100 | |
tell application "JSON Helper" | |
set bURL to "https://api.audioboom.com/tag/" & tag & "/audio_clips?page[items]=" & itemcount & "&page[number]=" & pagecount | |
set boos to fetch JSON from bURL | |
set myFile to open for access "Macintosh HD:Users:john:Desktop:audioboom:edutalk_" & pagecount & ".json" with write permission | |
set boohoo to make JSON from boos | |
write boohoo to myFile | |
close access myFile | |
set imageCount to count of audio_clips of body of boos | |
set mp3urls to {} | |
repeat with boo in audio_clips of body of boos | |
set end of mp3urls to high_mp3 of urls of boo | |
end repeat | |
end tell | |
repeat with mp3 in mp3urls | |
set cmd to "curl -L " & mp3 & " > " & downloadfolder & filenamefromurl(mp3) | |
do shell script cmd | |
end repeat | |
return cmd | |
on filenamefromurl(theurl) | |
set s to "url=\"" & theurl & "\"; echo \"${url##*/}\"" | |
return do shell script s | |
end filenamefromurl |
in case anyone is interested.
I had to run it 10 times, I guess I could have just made a loop but as I ended up downloading 890 mp3 for a total of 2.6 GB batches of 100 files at a time seemed like a good idea.
I am a wee bit worried that there are 2186 posts syndicated from audioboo on the Edutalk site, but there does seem to be a lot of duplication presumably caused by FeedWordPress.
Next Steps
I’ve now got all of the data and the mp3 files I can get.
I know how to post to WordPress from AppleScript, but I’ve discovered a couple of hurdles. I don’t seem to be able to add an enclosure with AppleScript and I can’t see how to ad multiple tags to a post.
The first is probably not a problem. These posts are all so old that they will not feature in our RSS feed. I would like to include all of the tags. I may end up creating a WordPress export file or try one of the csv import plugins. There is now not such a rush. I can test these approaches on this blog with my own boos.
I guess the main lesson to be learnt here is about the temporary nature of the free layer of the web. The AudioBoo app and service were wonderful in their day but reliance on free services costs.
The featured images is a gif captured with Licecap, of a mp3 download.
Microblogging adventures pt 2: Alfred post to WordPress for micro.blog
I’ve been beta testing micro.blog. There is a new page here for status type posts, these get sent to micro.blog/johnjohnston and to twitter.
This has renewed my interest in finding different ways to post to the blog especially for short posts that would have previously gone straight to twitter.
Microcast 5: Choices
Some thoughts about making choices about the software and systems you use, they may have hidden positives or negatives.
- Ian Guest (@IaninSheffield)
- Aaron Davis (@mrkrndvs)
- My Secret Art of Blogging – Read Write Respond
- Banning Ads Is Nice, but the Problem Is Facebook’s Underlying Model | Hapgood
- Sal Soghoian
Featured image, iPhone screenshot, edited in snapseed