Visar inlägg med etikett mac. Visa alla inlägg
Visar inlägg med etikett mac. Visa alla inlägg

måndag, september 10, 2012

Folder action script

I'm following a bunch of tv series which I download. The problem I was facing was to remember which episode I last viewed. I could always keep the last episode on my computer of course. But that soon took up to my disk space. Specially when the season had ended and it took another half year until next episode.

So I started to investigate what Mac OS X's Folder Actions was. 
It's action based on happenings in a specified folder. You apply a script to it and it does the rest. 

I'm having this script attached to a folder i call SEEN which I put all the watched episodes in when I'm done.

The script:


on adding folder items to this_folder after receiving these_items
 
 set dialogResult to display dialog "Empty content of file(s)? No way to undo!"
 
 if button returned of dialogResult is "OK" then
  
  repeat with i from 1 to number of items in these_items
   set this_item to item i of these_items
   
   do shell script ("cat /dev/null > " & quoted form of POSIX path of this_item)
   
  end repeat
  
  display dialog "Done."
 end if
 
end adding folder items to




So when I'm done watching an episode, I put it in my SEEN folder and a questions popups asking me if I want to empty the file. I click OK and voila, the file is 0 bytes.

lördag, december 04, 2010

Automator - run app with command line paramters

Every day I'm finding new tools in Mac OS X that are really helpfull. No need for all those mini powertools in Windows that you have to have hundreds off to accomplish your goals, everything is built into the OS.

Here I'm using Automator to run an other application, but with command line parameters.

You do like this:
  • Search for "shell" in the search field in Automator
  • Then use Run Shell Script (no need to change the default values)
  • Then enter: open /Applications/Google\\ Chrome.app --args -enable-default-apps (notice the double backslashes!)
Looks like there is tons of other useful featurs in Automator that I need to check out in the feature. They look really promising!