peelman Posted January 26, 2013 Share Posted January 26, 2013 So one of my peeves with Alfred and one of the edges I felt Quicksilver held against it was the ability to index just a folder, recursively to a defined level, and search those results. I keep all my media out on a NAS and having spotlight index those volumes just doesn't bode well for any of the involved parties, so I could never use Alfred quite like I could Quicksilver for quickly finding a TV show or Movie out on my file server. Thanks to script filters and some of jdfwarrior's great scripting hints, that's no longer true: require_once('extension_utils.php'); $utils = new ExtensionUtils(); $query = urlencode( "{query}" ); $results = array(); $pattern = "/$query/i"; $dir = "/Volumes/video/movies"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file != "." && $file != ".." && ($query && preg_match($pattern, $file))) { switch(pathinfo("$dir/$file", PATHINFO_EXTENSION)): case 'mkv': $icon = 'MKV.png'; break; case 'avi': $icon = 'AVI.png'; break; case 'm4v': case 'mp4': $icon = 'M4V.png'; break; default: $icon = 'movie.png'; break; endswitch; $item = array( 'uid' => 'show', 'arg' => "$dir/$file", 'title' => $file, 'subtitle' => "$dir/$file", 'icon' => $icon, 'valid' => 'true' ); array_push( $results, $item ); } } closedir($dh); } } echo $utils->arrayToXml( $results ); There's no good way (yet) to make this easily configurable, so posting it out as a full workflow for download seems a bit silly at this point, but perhaps this code might help somebody along the way achieve what they need. Link to comment
samvlu Posted March 16, 2013 Share Posted March 16, 2013 I feel your pain. It's possible for Alfred v1. By using the file search filter you can search only folders or only images. I'm working on getting this feature for Alfred 2. Link to comment
samvlu Posted March 16, 2013 Share Posted March 16, 2013 I got it working in Alfred 2!!! I'm posting a workflow now!! Link to comment
samvlu Posted March 16, 2013 Share Posted March 16, 2013 Here's the link to my post http://www.alfredforum.com/topic/995-find-folder-—%C2%A0search-by-folder-name-workflow/ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now