ddjfreedom Posted January 23, 2013 Share Posted January 23, 2013 (edited) An Alfred workflow for opening or revealing the most recently downloaded items in “~/Downloads”. http://d.pr/f/yLXo The items are sorted in decreasing order according to when they were added to the folder. Items are filtered by whether they contain the query as a subsequence. The result is displayed using the feedback functionality. Github repo: https://github.com/ddjfreedom/recent-downloads-alfred-v2 Use config.yaml in ~/Library/Application Support/Alfred 2/Workflow Data/recentdownloads.ddjfreedom/ to control the new default behavior: install_action: ask, install, open auto_start: ask, always, never Updated: 1. added the option to delete files (holding 'ctrl') (by fmr) 2. result's icon matches file's icon 3. added the option to move files to trash (holding 'cmd') (by fmr) 4. changed the default behavior of certain files: if the item can be installed (an application, an dmg file, a zip file containing those files, etc), the workflow will prompt the user whether to install it. After the installation, if the item installed is an application, the workflow will prompt the user whether to launch it. Edited April 3, 2013 by ddjfreedom David, Sridhar Katakam, ClintonStrong and 2 others 5 Link to comment
fmr Posted January 23, 2013 Share Posted January 23, 2013 Thanks. Sent you a pull-request on github adding the option to delete files (using script: rm {query}). Link to comment
ClintonStrong Posted January 23, 2013 Share Posted January 23, 2013 Nice workflow. Just a quick tip: you can tell Alfred to make the icon match a file's icon. In the resulting XML, it'd look something like this: <icon type="fileicon">/path/to/file</icon> Jono 1 Link to comment
ddjfreedom Posted January 23, 2013 Author Share Posted January 23, 2013 Nice workflow. Just a quick tip: you can tell Alfred to make the icon match a file's icon. In the resulting XML, it'd look something like this: <icon type="fileicon">/path/to/file</icon> Thanks. This is just what I was looking for. Link to comment
Florian Posted January 24, 2013 Share Posted January 24, 2013 Hey I suck at programming. Would you help on that? I tried installing your ruby gem but here is what i get: ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. xcrun: Error: could not stat active Xcode path '/Applications/Xcode45-DP4.app/Contents/Developer'. (No such file or directory) (of course i get a whole lot more but these seem to be the most important ones). I do have xcode installed as well as the command line tools. Link to comment
Enhorn Posted January 24, 2013 Share Posted January 24, 2013 I think moving the file to the trash instead of deleting it would be better, but other than that it's a great workflow. :-) Link to comment
jordic Posted January 24, 2013 Share Posted January 24, 2013 Great workflow! Two suggestions: Would it be an idea to differentiate between files and folders? Could you filter out the Icon? file?. It shows up if you've set a custom icon for the Downloads folder? One final remark: currently delete does not work for folder items. Link to comment
Enhorn Posted January 24, 2013 Share Posted January 24, 2013 BTW, changing the delete command to move the file/folder to the trash is mv {query} ~/.Trash Link to comment
fmr Posted January 24, 2013 Share Posted January 24, 2013 BTW, changing the delete command to move the file/folder to the trash is mv {query} ~/.Trash I'm aware of that but I prefer just deleting these files. They are usually (re-)downloadable anyway. But I can add another modifier to move to trash. Then we'll both be happy :-) included in my latest pull request on github: https://github.com/ddjfreedom/recent-downloads-alfred-v2/pull/2 Enhorn 1 Link to comment
ddjfreedom Posted January 24, 2013 Author Share Posted January 24, 2013 Hey I suck at programming. Would you help on that? I tried installing your ruby gem but here is what i get: ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. xcrun: Error: could not stat active Xcode path '/Applications/Xcode45-DP4.app/Contents/Developer'. (No such file or directory) (of course i get a whole lot more but these seem to be the most important ones). I do have xcode installed as well as the command line tools. According to http://stackoverflow.com/questions/11961032/xcrun-error-could-not-stat-active-xcode-path-volumes-xcode-xcode45-dp1-app-c, you need to run sudo xcode-select -switch /Applications/Xcode.app And I've updated the link in the original post. Now delete works both on files and folders, and hoding 'cmd' to move item to Trash. You can also download it here: http://d.pr/f/te4d Link to comment
pasamuels Posted January 24, 2013 Share Posted January 24, 2013 I've sent a couple of pull requests - one for improved native handling of deletions and another to remove the dependancy on nokogiri. Link to comment
Jono Posted January 24, 2013 Share Posted January 24, 2013 According to http://stackoverflow.com/questions/11961032/xcrun-error-could-not-stat-active-xcode-path-volumes-xcode-xcode45-dp1-app-c, you need to run sudo xcode-select -switch /Applications/Xcode.app I tried that but get the following: Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.6 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.6/ext/nokogiri/gem_make.out I've sent a couple of pull requests - one for improved native handling of deletions and another to remove the dependancy on nokogiri. I'll look forward to that. Link to comment
ddjfreedom Posted January 24, 2013 Author Share Posted January 24, 2013 (edited) I've sent a couple of pull requests - one for improved native handling of deletions and another to remove the dependancy on nokogiri. Thanks. Link in the original post is updated. Also http://d.pr/f/55Ia Edited January 24, 2013 by ddjfreedom Link to comment
ddjfreedom Posted January 24, 2013 Author Share Posted January 24, 2013 It's now also in AlfPT Enhorn and Jono 2 Link to comment
hankydysplasia Posted January 25, 2013 Share Posted January 25, 2013 Thanks for the workflow. One of my biggest pet peeves is wasting time finding what I just downloaded. This shares the same keyword as "View Recent Folders." Easily changeable, just thought you'd like to know. Link to comment
Jono Posted January 25, 2013 Share Posted January 25, 2013 It's now also in AlfPT Thanks! Link to comment
politicus Posted January 25, 2013 Share Posted January 25, 2013 Hi, Very interesting workflow. My problem is I do not see any items filtered. I type this workflow keyword, "Recent Downloads" is selected then I type "enter". Then ... I can't do anything. After typing "enter", I tried to insert the name of the latest download, it didn't work. I even tried to type "enter", holding ctrl or cmd or option but my latest download was still there... I have nokogiri installed "require 'nokogiri' => True". I am pretty sure I didn't understand how to make it work properly. Could you elaborate for the newbie that I am ? Thank you. Link to comment
ddjfreedom Posted January 25, 2013 Author Share Posted January 25, 2013 Hi, Very interesting workflow. My problem is I do not see any items filtered. I type this workflow keyword, "Recent Downloads" is selected then I type "enter". Then ... I can't do anything. After typing "enter", I tried to insert the name of the latest download, it didn't work. I even tried to type "enter", holding ctrl or cmd or option but my latest download was still there... I have nokogiri installed "require 'nokogiri' => True". I am pretty sure I didn't understand how to make it work properly. Could you elaborate for the newbie that I am ? Thank you. I'm not exactly sure why. One reason may be that folder ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data doesn't exist. The workflow will store some data in a folder created in that folder, so if it doesn't exist, the workflow fails. Maybe you can use the newest build of Alfred 2. I think it will automatically create the folder. Or you can manually create it. Link to comment
ddjfreedom Posted January 26, 2013 Author Share Posted January 26, 2013 (edited) changed the default behavior of certain files: if the item can be installed (an application, an dmg file, a zip file containing those files, etc), the workflow will prompt the user whether to install it. After the installation, if the item installed is an application, the workflow will prompt the user whether to launch it. Use config.yaml in ~/Library/Application Support/Alfred 2/Workflow Data/recentdownloads.ddjfreedom/ to control the new default behavior: install_action: ask, install, open, cancelauto_start: ask, always, never new version is on AlfPT and http://d.pr/f/CAIi Edited January 26, 2013 by ddjfreedom Link to comment
politicus Posted January 27, 2013 Share Posted January 27, 2013 Hi, I manually created the "Workflow Data" folder + installed the newest version of the workflow. It is working like a charm. Thank you ! Awesome job. Link to comment
David Posted January 27, 2013 Share Posted January 27, 2013 Thanks, very handy.. fyi, Recycle bin is showing up in the list for me :-) Link to comment
scottisloud Posted January 28, 2013 Share Posted January 28, 2013 Just another note, Looks like it doesn't know how to handle .zip files. If the user selects a zip file and presses enter, nothing happens. Link to comment
ddjfreedom Posted January 28, 2013 Author Share Posted January 28, 2013 Just another note,Looks like it doesn't know how to handle .zip files. If the user selects a zip file and presses enter, nothing happens. I guess that the name of the zip file contains white space? Sorry about that. Just updated the workflow to address this. http://d.pr/f/YoTI Link to comment
twinpeaks Posted January 28, 2013 Share Posted January 28, 2013 A couple of things. - I just want to use the script to display the most recent downloaded file. I have no use for the install etc... action you have added. Which is nice but I had disabled that from the v1 script othijus shared. 1) Are there any plans to have the script be capable of going down at least one directory to deep for those of us who auto-organize downloads with apps like Hazel and Glims for Safari? 2) I am not getting accurate results. Default clean install of 10.8.2 with Xcode and command line tools etc... but I can go to macupdate.com - download 3 files in a row and they are usually mixed up a bit with older folders residing in ~/Downloads (2-5 days old) appearing before the just downloaded files. What are your system specs? I never had these problems with otijhuis's extension for alfred v1 so I am not sure why the results I am receiving are so off. Any ideas? Ruby v1.8.7 (default 10.8 version) Perhaps it is Ruby or something else, so please if you do not mind would you share your system specs with me so I can try to figure out what is causing this behavior? And lastly, anyway we might see the script be able to filter down one level to view downloads organized into dated folders? Thanks for sharing this! I really hope I can get it to work as I had posted a request for a script just like this 4 or 5 days before you posted this workflow. Cheers! Link to comment
ddjfreedom Posted January 29, 2013 Author Share Posted January 29, 2013 Thanks, very handy.. fyi, Recycle bin is showing up in the list for me :-) Is that also hidden? I just filter out all file names starting with '.'. I'll fix this. A couple of things. - I just want to use the script to display the most recent downloaded file. I have no use for the install etc... action you have added. Which is nice but I had disabled that from the v1 script othijus shared. 1) Are there any plans to have the script be capable of going down at least one directory to deep for those of us who auto-organize downloads with apps like Hazel and Glims for Safari? 2) I am not getting accurate results. Default clean install of 10.8.2 with Xcode and command line tools etc... but I can go to macupdate.com - download 3 files in a row and they are usually mixed up a bit with older folders residing in ~/Downloads (2-5 days old) appearing before the just downloaded files. Just realized that it will always check if there are stuff to install. Sorry about this. I'll fix it. 1) Do you mean display items from Downloads folder and all its sub-folders? Or display items from Downloads folder and walking down folders? If the latter, I'll have to set folder's 'valid' key to "no", and no operation can operate on it. 2) The workflow uses mdls -name kMDItemDateAdded -raw "Filename" to get the time when an item is added to Downloads, and use this to sort the item. Because mdls is quite slow, the workflow caches the result in a file under ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/recentdownloads.ddjfreedom I'm guess the cache becomes inconsistent with the order of files in Downloads. Another possible reason is that the workflow uses file name as uid, maybe Alfred changes the results a bit. 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