Author Archives: Kevin

Save list of folder contents

Published / by Kevin / Leave a Comment

This AppleScript will create a file containing a tree style list of all files inside the chosen directory and save that list in a file created in that directory. The list file will include the path of the listed directory as well as the date and time it was saved.

The default directory in the choose dialog is the folder of the Finder’s frontmost window unless there are no Finder windows. In which case the default is the Desktop folder.

It does not follow aliases (not sure about symlinks) and will indicate an alias by placing ” [alias]” behind the file name.

This is actually a modified version of a script that’s been around the web for years.

global fileList

on listFolder(f, s)
  list folder f
  repeat with i in the result
    if alias of (info for alias (f & i)) then
      set fileList to fileList & s & i & " [alias]" & return
    else
      if package folder of (info for alias (f & i)) then
        set fileList to fileList & s & i & return
      else
        if folder of (info for alias (f & i)) then
          set fileList to fileList & s & i & "/" & return
          listFolder(f & i & ":", s & "    ")
        else
          if first character of i is not "." then
            set fileList to fileList & s & i & return
          end if
        end if
      end if
    end if
  end repeat
  return fileList
end listFolder

try
  tell application "Finder" to set cwd to (POSIX path of (folder of window 1 as string)) as POSIX file
on error
  set cwd to path to desktop folder
end try
set theFolder to (choose folder "Select a folder to list:" default location cwd) as string

--This will get the name of the folder for use in the name of the generated file
set folderName to name of (info for (theFolder as alias))

--This will get the Unix style path of the folder for info purposes inside the file itself
set folderPath to POSIX path of theFolder

set fileList to "# File list of: " & folderPath & " on " & (current date) & return & return
set fileList to listFolder(theFolder, "")

set listFile to ((theFolder) as text) & folderName & " list of files " & (do shell script "date \"+ %Y-%m-%d %H%M\"") & ".txt"

tell application "Finder"
  set newFile to (open for access file listFile with write permission)
  set eof newFile to 0
  write fileList to newFile
  close access newFile
  open listFile as alias
end tell

iPhoto import from folders AppleScript

Published / by Kevin / Leave a Comment

Preface: Having upgraded my phone (Nokia N8) firmware to “Belle” — whatever version that is, the Nokia Multimedia Transfer application no longer imports photos to iPhoto.* Tragic because the camera is the sole reason I bought this phone. Ordinarily this would not be a problem since the phone uses a “DCIM” folder at the drive root and can store images with 8 character names (5 of which you set yourself). But not every photo app does store them there or with a “proper” name. Even though there exists an “Images” folder in the drive root that I know gets used, Mass Storage.app does not access it. Could be another naming convention similar to DCF

This is an AppleScript to get around this limitation, and to allow (in my case at least) the importing of camera files named by date. In short you choose which folders you want this script to tell iPhoto to import from and can be used with any folder(s), no specific device required.

Notable: Uses ‘defaults’ to store and load folder paths in a property list (.plist) file.
Continue reading

Hide thumbnails of certain users content on Flickr

Published / by Kevin / Leave a Comment

Using CSS you can identify and hide thumbnails from users. Makes it a bit easier to skip past or ignore people who can’t help but taint your favorite groups with inappropriate or offensive material or idiotic political themed collages. Nothing kills my buzz like having the local flora, fauna, and other interesting things interrupted with fear mongering hate rhetoric.

/**** A-holes on Flickr ****/
a[href*="/USER_ID/"]:before {
  content: "NUTJOB ";
}
a[href*="/USER_ID/"] img {
  display:none !important;
}

This does not hide the actual content on its own page or disable any links. It just lets you easily identify items to avoid while hiding the thumbnail.

The USER_ID can be culled from the URL the item resides at. For instance my ID in context: http://www.flickr.com/photos/strawhousepig/ Keep in mind that not all IDs are human readable. The default value is a seemingly random string.

Netflix search bookmarklet

Published / by Kevin / Leave a Comment

Drag this link to your bookmarks, or copy paste the URL.

Search Netflix

What it does: Takes the current selected text and sends it to Netflix.com as a search string. If no text is selected a prompt window will pop-up allowing you to manually enter a term. Also, if you are browsing The Internet Movie Database (IMDb) when you select it the title of the page will be used as the search string.

What it is:

is_imdb=/\.imdb\.com/;
if(is_imdb.test(document.domain)){
  q=document.title.split(' - IMDb',1);
}else{
  if(getSelection()!=''){
    q=getSelection();
  }else{
    void(q=prompt('Enter search term (Netflix)',''));
  }
}
if(q){
  window.open('http://netflix.com/WiSearch?v1='+escape(q));
}

Mac ready “lightbox” close widget

Published / by Kevin / Leave a Comment

I use a Mac, you use a Mac. Our close window button is in the top left corner of the window so it’s convenient when a JavaScript pop-over puts the “button” there, though most don’t. A few I run into I’ve decided to throw some CSS at to fix them.

/**** Mac ready "close" widget ****/
/* Wordpress admin "More info..." */
div#TB_ajaxWindowTitle {
  position:absolute;
  top:0px;
  left:25px;
  float:none !important;
  display:inline !important;
}
div#TB_closeAjaxWindow {
  display:inline !important;
  float:left !important;
  clear:left !important;
}
/* Amazon */
div.ap_close {
  left: 24px !important;
}
span.ap_closebutton {
  float:left;
  clear:left;
}
/* "Fancybox" */
a#fancybox-close {
  left:-15px !important;
}
/* "MultiBox" */
div.MultiBoxClose {
  left:-26px !important;
}
/* Disqus profile */
a.dsq-modal-close-btn {
  position:absolute !important;
  top:10px !important;
  left:10px !important;
}

This would of course go into your user defined CSS file. Which in Safari can be added at Safari > Preferences | Advanced – Style sheet: