michaelfox + automation   108

Platypus | Sveinbjorn Thordarson
Platypus is a developer tool for the Mac OS X operating system. It can be used to create native, flawlessly integrated Mac OS X applications from interpreted scripts such as shell scripts or Perl, Ruby and Python programs. This is done by wrapping the script in an application bundle directory structure along with an executable binary that runs the script.

Platypus makes it easy for you to share your scripts and programs with those unfamiliar with the command line interface, without any knowledge of the Mac OS X APIs -- a few clicks and you will have your own Mac OS X graphical program. Creating installers, maintenance applications, login items, launchers, automations and droplets is very easy using Platypus.

Supports shell scripts, Perl, Python, PHP, Ruby, Expect, Tcl, AppleScript
Supports arbitrary interpreter specification
Executing scripts with root privileges via Apple's Security Framework
Drag and drop files or text snippets, which are then passed to the script as arguments
Can display graphical feedback of script execution as progress bar, text window with script output, WebKit HTML rendering or status item menus
Can create applications which run in the background (LSUIElement)
Sophisticated app bundle configuration for associated file types, identifier, version etc.
Graphical interface for bundling support files with script
Built-in script editor, or linking with external editor of choice
Set own application icon or select from presets
Command line tool for automating script application bundling
"Profiles" which can be used to save configurations
tools  scripting  automation  osx  perl  python  app 
december 2011 by michaelfox
Post Grabber sniffs out POST data, generates curl scripts
Every now and then I find myself needing to automate some web requests, either to download using something a little more robust than a web browser, scrape some web content, or to maintain a session. That automation can be a bit of a pain if there’s a form submission involved, because it means opening up the page source, finding the form and any connected javascript code, and figuring out what fields are submitted.

A little utility I just put together does that for you: Post Grabber detects POST data and generates an equivalent “curl” command that can be used in shell or Automator scripts.

Post Grabber works with its own internal browser, so it can intercept POST submissions directly. That means it works with HTTPS, unlike the traditional web sniffer approach.

Download the app, or see the source on GitHub.
automation  commandline  curl  http  tools  apps 
september 2011 by michaelfox
del.icio.us info for URL: a Mac OS X system service
This is a service that, given a URL as input, will open the del.icio.us info page for the URL in your favorite browser. Here's an example of an info page.

The service was written in zsh shell-script and turned into a service with ThisService.
service  osx  automation  url  info  delicious  zsh  shell  script 
september 2011 by michaelfox
AppleScript: Launching Scripts From Links

Home
Features

Learn
Explore

Launch Scripts from Webpage Links
AppleScript applications can interact with websites displayed on your computer to perform tasks and display information. This is done through the process of the AppleScript application registering itself with the OS as the handler of specific URL protocols and schemes.

The following describes how to create your own helper script applications.

THE INFO.PLIST FILE

When you save the script as an application bundle, it will contain the standard Mac OS X bundle elements including an XML property list file defining important aspects of the script application.

To access the Info.plist property list, click on the script application with the Control key held down to access the Finder Contextual Menu. Choose Show Package Contents from this menu to open the script application bundle in a new window. Open the Contents folder within the new window to reveal the Info.plist file. Open this file in a text or property list editor and add the following XML keys and values to the property list.

To identify the Application, add the following lines to the property list, replacing the blue placeholder text shown here with a unique bundle identifier for your application:

<key>CFBundleIdentifier</key>
<string>com.apple.AppleScript.WebpageHelper</string>
To identify the URL handler that triggers the applet, add the following item to the property list, replacing the blue text with title of your URL protocol and the URL scheme of your protocol:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Webpage Helper</string>
<key>CFBundleURLSchemes</key>
<array>
<string>webpagehelper</string>
</array>
</dict>
</array>
applescript  links  url  osx  handler  protocol  scripting  html  forms  dialogs  automation  cli  shell  form  dialog 
december 2010 by michaelfox
AppleScript
AppleScript is Apple's powerful and versatile native scripting technology for Mac OS X. With AppleScript, you can control, and communicate among, applications, databases, networks, Web services, and even the operating system itself. You can make your Macintosh applications scriptable so that users can write scripts to automate operations they would rather not do manually, from simple tasks to complex workflows involving multiple applications. AppleScript Studio enables you to build individual scripts and workflows into rich, functional Aqua-compliant applications, and is useful for rapid prototyping, automated testing, and other kinds of development. By taking advantage of the AppleScript support integrated throughout Mac OS X you empower your users to be creative in solving problems on their own, and you don't have to build a separate solution in anticipation of their every need.
applescript  automation  osx  programming  reference 
december 2010 by michaelfox
Building An AppleScript-Based Automator Action
Building An AppleScript-Based Automator Action

by Benjamin S. Waldie

There has been a lot of excitement in the developer community around the release of Mac OS X 10.4. Unique technologies like Automator, Dashboard, and Spotlight are providing new opportunities for Mac developers to build unique tools that appeal to users everywhere. This month, we are going to walk through the process of developing for one of these great new technologies, Automator.

Automator is Apple's new technology that is helping users everywhere to begin automating repetitive and time consuming tasks in their own unique workflows, allowing them to become more efficient. By placing actions, which are single automated tasks, together in a sequence, users are able to construct a fully automated workflow, without the need to write a single line of code. How does this help us, as developers, you may be asking? Well, someone needs to create the actions that give users this power.

Automator actions are built in Xcode, and are typically developed using either Objective-C, AppleScript, or a combination of these, and possibly other languages. Objective-C may be used to develop actions that interact with core components of the OS, or applications with a public API. AppleScript may be used to develop actions that interact with any scriptable application or process on the Mac.

In this article, we will walk through the process of creating a basic Automator action with AppleScript. This brief overview should provide you with a basic understanding of the primary steps involved in creating a simple AppleScript-based action. Once you understand the basic concepts of building an action, then you can take additional steps on your own to begin expanding your knowledge through additional resources. Before long, you will be creating complex actions that interact with a variety of scriptable applications or processes, and sharing those actions with users. Obviously, it should go without saying that you will need Mac OS X 10.4 and Xcode 2 or higher to create an Automator action.
applescript  scripting  automation  osx  automator  development  reference 
december 2010 by michaelfox
Introduction to Database Events
Introduction to Database Events

by Benjamin S. Waldie

Data storage and access is an important part of AppleScripting, particularly in complex AppleScript-based projects. Some scripts may need to store user-entered data for later reference, perhaps during an entirely new session. Some may need a location to log activity or errors during processing. Others may need to access structured data, in order to do something fairly complex, such as building a catalog.

In this month's column, we will discuss the use of Database Events, a new and exciting feature in Mac OS X, for storage and access of data during script execution.
applescript  database  data  events  scripting  automation  sqlite  osx 
december 2010 by michaelfox
10.4: Move MP4 films to iTunes via Automator - Mac OS X Hints
I watch quite a few DVDs through my iPod Video on my way to and from work. I usually convert my films with Handbrake in MP4 format to the Desktop. I have iTunes set to organise my music and films automatically, which means that all files dragged into it are copied to ~/Music -> iTunes -> iTunes Music. I wanted to find a solution to avoid copying the films and have them put in my film library with Automator.

First, I found out that all my films are stored in a folder called "Unknown artist." Moving the file there before loading it in iTunes will avoid the copy process. Secondly, I found out that the iTunes Automator action for importing media into iTunes couldn't import MP4 files. I had to use an AppleScript to do that instead. So here are the steps in my Automator workflow:
Finder library, Get Specified Finder Items action.
Finder library, Move Finder Items action, to ~/Music/iTunes/iTunes Music/Unknown Artist/
Automator library, Run AppleScript action, with the following AppleScript:
on run {input, parameters}

tell application "iTunes"
launch
set this_track to add input to playlist "Library" of source "Library"
duplicate this_track to playlist "film"
end tell

return input
end run
I then save it into ~/Library -> Workflows -> Applications -> Finder" as iTunes Film. Then all I need to do is control-click on the film on the Desktop and chose Automator > iTunes Film from the pop-up menu.
itunes  automation  automator  applescript  media  video  mp4 
december 2010 by michaelfox
AppleScript Language Guide: Introduction to AppleScript Language Guide
This document is a guide to the AppleScript language—its lexical conventions, syntax, keywords, and other elements. It is intended primarily for use with AppleScript 2.0 or later and Mac OS X version 10.5 or later.

AppleScript 2.0 can use scripts developed for any version of AppleScript from 1.1 through 1.10.7, any scripting addition created for AppleScript 1.5 or later for Mac OS X, and any scriptable application for Mac OS v7.1 or later. A script created with AppleScript 2.0 can be used by any version of AppleScript back to version 1.1, provided it does not use features of AppleScript, scripting additions, or scriptable applications that are unavailable in that version.
documentation  reference  applescript  osx  automation 
december 2010 by michaelfox
Xcode Workspace Guide: User Scripts
User scripts are shell scripts you can define in your workspace and that you can execute by choosing them from the User Scripts menu or using a keyboard shortcut. With these scripts you can invoke command-line tools and perform operations on the selected text. For example, you can sort the selected lines in the text editor.

Xcode provides a number of mechanisms for working with user scripts. These features include:

*

The ability to execute text in a text editor window as a shell command or series of commands
*

A number of built-in script variables and utility scripts you can use in menu scripts or other scripts

This chapter describes how to manage and use Xcode user scripts.
xcode  user  automation  applescript  textmate  shell 
september 2010 by michaelfox
Looking for help with a script to automate VLC - The UNIX and Linux Forums
#!/bin/bash # # Creates a list of all files in all Simpsons folders and then # plays so many random episodes with VLC Media Player. # Created by Uncertain # Filenames and paths. path1=/home/zero/Videos/ path2=/home/zero/Videos/Simpsons list=/home/zero/Videos/Simpsons/episodes.txt # Check for the list. If it's in ~/Videos, fine. # If it doesn't exist, create it in ~/Videos. if [ -f $list ] then echo "List found at $list" else echo "Episodes list not found. Creating list arranged by season & episode..." && cd $path1 && find ~/Videos/Simpsons -name '*.avi' -o -name '*.mpg' -o -name '*.mp4' -o -type f -size +20M | sort > $list && echo "Done. List created at: $list" fi # Set the number of episodes to play. Episodes are # roughly 20 mins, so three episodes to every hour. repeat=3 cycles=0 while [ $cycles -ne $repeat ] do echo $cycles cycles=$(( $cycles + 1 )) # Read the list, select one random line. LowerBound=1 RandomMax=32767 UpperBound=$(cat $list | wc -l) RandomLine=$(( $LowerBound + ($UpperBound * $RANDOM) / ($RandomMax + 1) )) # Use sed to grab the random line. episode=$(sed -n "$RandomLine{p;q;}" "$list") # open the random line in VLC vlc -vvv --fullscreen "$episode" vlc:quit # Close the episode count loop... done # ...and then... exit
vlc  automation  scripting 
august 2010 by michaelfox
Form auto-fill bookmarklet / Stoyan's phpied.com
This is a bookmarklet. You go to page that has one or more forms and you click the bookmarklet. It completes the form for you with some random data. The whole thinking was to have a form ready to be submitted and generating as less validation errors as possible. Here are some details:

* All defaults are kept as they are
* All passwords fields are completed with the same password, in case there is a password/password confirmation combo. The default password is "secret"
* If a text field has the string "email" in its name, the auto-generated value would be a random string @ example.org
* If a text field has the string "name" in its name, a name-looking value will be generated.
* All checkboxes will be checked (who knows which one of them might be "Accept terms" or anything else that is required)
* Multi-selects will have a random number of random options selected
javascript  forms  firefox  autocomplete  development  tools  autofill  automation  testing  bookmarklets 
august 2010 by michaelfox
Create fixed size thumbnails with ImageMagick | Matteo Spinelli's Cubiq.org
ImageMagick is powerful suite of applications to create, edit, convert and compose bitmap (and some vector) images from the terminal. It's an essential tool for any web designer if you can get your head around it.
php  thumbnails  scripting  automation  image  graphics  tools  imagemagick 
august 2010 by michaelfox
lvtrii's iTunes-Library-Parser at master - GitHub
PHP Class to parse iTunes Library XML Files. See example.php for example usage. The library is an array of track objects. The track object has no methods, but contains the following properties: Track_ID Name Artist Album Genre Kind Size Total_Time Track_Number Year Date_Modified Date_Added Bit_Rate Sample_Rate Comments Play_Count Play_Date Play_Date_UTC Persistent_ID Track_Type Location File_Folder_Count Library_Folder_Count
itunes  xml  parser  php  development  automation  library 
june 2010 by michaelfox
Managing Multiple Sized Copies of Movies in iTunes « Clark's Tech Blog
OK, I’ll confess upfront I’ve not tried this one yet although I hope to tomorrow. I got this info from Ars.

The basic problem is when you have a movie you’ve ripped but you want to watch it both on your Apple TV and your iPhone. Now ideally you’d want two different sizes. The iPhone doesn’t need the resolution you’d rip for the Apple TV plus you want the size to be as small as possible. Now if you’ve ever bought a show from iTunes you’ll note that Apple gives you both hi-res and low res versions. How do they do this? Well it turns out it’s just a tag on the MPEG-4 file. And there is a shell script to set those tags so you can do it with your own files.

First download and install mp4v2. Yes, you have to compile it. However if you have MacPorts you can also install it that way.
mac  osx  snow  applescript  python  scripting  automation  itunes  organization  mp4v2  multiple  track  video  movies 
may 2010 by michaelfox
Cleaning iTunes Pt. 3: Album Names « Clark's Tech Blog
the trickiest part of cleaning ones iTunes library is looking up missing album information. There are a few applications that do this by mathematically analyzing the song’s music itself against a library. The problem is that this isn’t that accurate. There was an old app that did this (no longer available) called iEatzBrains or something like that. Unfortunately I made the mistake of running it against a bunch of tracks after testing it. Only then did I find that it’s accuracy was about 90%. So to be honest I am still finding tracks that had their artist and album names “revised” because of that. (I’d say that event caused about half of my library errors)

So I’m really leery of that sort of thing. However trying to find a script that could give a guess at album names was surprisingly hard. There weren’t any. There was a database of album information called discogs but it really didn’t let you search by track info. It was all oriented around correct album information. (Although it is useful for other metadata – as we’ll see in the future)

I did some pretty elaborate Google searching and remarkably this isn’t a problem that folks have solved. (Or at least they haven’t put solutions up online) Fortunately I found a solution from an unusual source: Apple.

Apple actually has a web API for searching the iTunes store. The documentation (oddly labeled “confidential” but publicly available) is quite helpful. What I did was to do an artist search returning just track information. Effectively getting a list of all songs by that artist. The returned data is even in JSON format rather than XML! This means I can make all the returned data into a Python dict with the simplejson module and a single call.

All I do then is just compare the selected song in iTunes (using Appscript) with the songs in the iTunes store. Now I could make this part a bit more intelligent by normalizing unicode characters and perhaps removing padding words like “a” or “the.” Thus far I’ve not had any trouble so I’ve not bothered making it “brighter.”

To avoid the problem of entering album information that is wrong and then never being able to find the changed files I put pretty extensive comments in each track. If the song could be from more than one album I put the other alternative albums in. Even if (as is typical) there’s only one album the track is on I put a note in the comments.

What’s surprising is how short the code is. (Take out all the comments in the code and there really isn’t much to it) My previous attempt using discog’s XML was at least 3 – 4 times as long and not nearly as accurate.
mac  osx  snow  applescript  python  scripting  automation  itunes  organization 
may 2010 by michaelfox
Fix iTunes Names « Clark's Tech Blog
There are some amazing Python programmers out there who can do some pretty impressive and abstract stuff. However most of what I use Python for is as a quick and dirty scripting system. I’m rarely writing full elegant programs. Rather I just want to get something done and done quickly. Most of the time I’m not looking for every potential boundary problem. I’ll be able to tell if it doesn’t do what I want!

One thing I sometimes want to do it fix names in iTunes. That’s because I have some files where the name is mangled. (It’s all lower case, it has the track number prepended, or the like) While it’s possible to write a general case solution to this problem it’s much better to just have a script framework and modify a few lines for the particular problem.

Here’s how I do it using Appscript.
mac  osx  snow  applescript  python  scripting  automation  itunes  organization 
may 2010 by michaelfox
Cleaning iTunes Pt. 1 « Clark's Tech Blog
I wanted to start with the finding of duplicates. Now you could use a program like fdupes or dupes.py (discussed a few weeks ago). Those aren’t ideal. In the past I’ve used Doug’s Applescripts. He has several useful scripts. One is Remove Dead Tracks which gets those entries where the file is long gone. (I don’t know how that happens – it’s usually stuff I don’t want anyway) His other famous script is Corral iTunes Dupes which I’ve used in the past to find duplicate tracks.
mac  osx  snow  applescript  python  scripting  automation  itunes  organization  duplicates  dupin  apps 
may 2010 by michaelfox
Cleaning iTunes Pt. 4: Artist Names « Clark's Tech Blog
What this script does is look up the standardized spelling for artists. As ever I work on a playlist you create. In this case the playlist “__Fix Arists” (without the quotes) I’d suggest adding to this list manually rather than trying to automate it. Both for safety (because it’s easy to undo if you just have a single artist in there) but also it just keeps things simple. If you need you could easily add in a routine to work on a selection. I’ll put that in the script but comment it out.
mac  osx  snow  applescript  python  scripting  automation  itunes  organization  musicbrainz  metadata 
may 2010 by michaelfox
Cleaning iTunes Pt. 2: Title Case « Clark's Tech Blog
This is the second in a series of posts on cleaning up my library in iTunes. Last time we discussed using Dupin to find duplicates. This week I want to focus on the problem of capitalization of song names. If you are like me you have a few songs in your library where the case is screwed up. (Sometimes even the database of CD song names has some mistakes – most of my bad titles were from ripped CDs) What I want to do is use TitleCase (discussed last week) to check to see if the titles are correct. Because some titles are supposed to be weird rather than just automatically fixing things I just add the files to a special playlist. To keep my “fix it” playlists separate from my regular ones I always prepend them with two underscore characters. (I usually then delete them when I’m done — although you don’t have to)
mac  osx  snow  applescript  python  scripting  automation  itunes  organization 
may 2010 by michaelfox
TextMate & Python « Clark's Tech Blog
TextMate is currently my editor of choice. For a long time I was a BBEdit fan but until recently it had really fallen behind. (I’ve heard the latest version is quite good though) Given a choice (at the time) between using XCode, paying to upgrade my copy of BBEdit, or buying TextMate, I went with TextMate. Now TextMate does have a few flaws. (The lack of real Applescript support for the text window and a slit pane window drive me bonkers) The author has been doing a rewrite but no one know when it’ll be out.

Where TextMate shines though is its thorough integration with the shell and its ability to call scripts, such as Applescript. (See, for instance, http://macromates.com/screencast/applescript-1.mov">this screencast showing how to run Applescripts from within TextMate instead of Script Editor.) It also has a lot of advanced editor features such as code completion, keyword tagging, and so forth. There’s a great tutorial online for using TextMate I’d suggest you check out. It’s very powerful and once you get used to it you’ll never want to leave it.
mac  osx  snow  applescript  python  scripting  automation  textmate 
may 2010 by michaelfox
Shell and Automator « Clark's Tech Blog
To start let me give a great way to keep infrequently used shell scripts. If you are like me you have some shell commands you run only occasionally. For instance when I am trying to debug a network I often use nmap (installed via MacPorts). However because I do it so infrequently I have to remember the arguments to the command and then how I mapped the NAT. (Some networks use 10.0.0.x while others use 192.168.1.x and others 192.168.0.x) So I put the following as a service in Automator.
mac  osx  snow  applescript  python  scripting  automation  shell  automator 
may 2010 by michaelfox
Making Applescript More Useful « Clark's Tech Blog
The best way to really leverage Applescript is to turn on GUI scripting and enable the Script menu in the menu bar. Go to Applications > Applescript > Applescript Utility.app. This is a nice little application Apple supplies that will turn these on. I’ll not talk about GUI scripting but it lets you control things like menus even if an application is not written to support scripting. So it’s nice for certain tight spots where an application has either no or poor Applescript support.

The Applescript menu creates a little menu item listing scripts for that application. Even though I’m not a fan of Applescript the fact is that there are a lot of great little utilities. Running them from the Applescript menu is much, much faster than running a separate application (say created from Apple’s Script Editor).
mac  osx  snow  applescript  python  scripting  automation 
may 2010 by michaelfox
Applescript Shell « Clark's Tech Blog
I prefer to script, as much as possible, in Python + Appscript. However sometimes it’s just more convenient to do it in Applescript. (Actually, some of the shorter Python scripts I do would probably be better done in Applescript – but I like doing them in Python so I can quickly extend them when the need arises.) What would be nice is to be able to have shell scripts that execute Applescript the way you can have them execute Python, bash, Ruby or so forth.
mac  osx  snow  applescript  python  scripting  automation  shell 
may 2010 by michaelfox
Python & Appscript Tools « Clark's Tech Blog
First download both ASTranslate and ASDictionary from the Appscript tool page. ASDictionary adds a help feature to Appscript. ASTranslate translates Applescript into Python. Both are essential if you want to script.

Next install iPython on your computer. Ignore most of the pages on iPython installation Google gives you. With recent versions of OSX Python comes with easy_install. Just type easy_install ipython at the command line and everything should get installed. If your system doesn’t have easy_install then install setuptools which includes it. (As an aside, if you’ve jailbroken your iPhone then iPython makes a wonderful calculator from the Cydia terminal)
python  applescript  mac  osx  snow  scripting  automation  asdictionary  astranslate  ipython  install  setup  config  environment 
may 2010 by michaelfox
« earlier      

related tags

addons  addressbook  aliases  ant  app  apple  applescript  appletv  apps  archive  archiving  asdictionary  astranslate  atom  autocomplete  autofill  autohotkey  automation  automator  background  backup  bash  beautifier  bin  bindings  bittorrent  bookmarklets  browser  build  building  cheat  cheatsheet  cli  code  codegenerator  colorsync  commandline  compression  config  continuousintegration  control  convert  crawler  cron  cruisecontrol  curl  customization  data  database  delicious  delta  deployment  development  dialog  dialogs  documentation  download  dpi  dropbox  dupin  duplicates  dvdrip  dvdshrink  email  environment  events  example  ffmpeg  file  files  filing  filter  finder  firefox  flash  flv  folderactions  form  forms  generator  git  github  googlereader  graphics  gtd  gui  hacking  hacks  handbrake  handler  hazel  howto  html  http  id3  ifttt  image  imagemagick  images  info  inspiration  install  interfacebuilder  iphone  ipython  itunes  javascript  jekyll  key  keybindings  keyboard  keyboardmaestro  launchbar  launchd  learning  library  lifehacker  links  lion  list  lua  mac  mac.cron  macosx  markdown  marked  media  menu  metadata  mouse  movies  mp3  mp4  mp4v2  multiple  music  musicbrainz  office  omnifocus  optimization  organization  osax  osx  paperless  parser  parsing  pdf  perl  phing  php  phpundercontrol  playlist  plist  plugins  podcasts  productivity  programming  project  protocol  proximity  python  quartz  reference  rename  repo  resources  rss  ruby  safari  scanner  scirpts  script  scripting  scripts  selenium  service  services  session  setup  shell  shortcuts  smartplaylist  snippet  snow  software  sqlite  staging  sublime  svn  tabs  tagging  tags  template  testing  textmate  thumbnails  tips  tools  toread  track  transmission  tutorial  tv  tweaks  twig  ultimatebuild  unittesting  uri  url  user  utilities  utility  version  versioncontrol  via:brettterpstra  video  visualhub  vlc  webarchive  webdev  wget  window  workflow  xcode  xib  xml  xslt  xsltproc  youtube  zsh 

Copy this bookmark:



description:


tags: