vitor Posted January 13, 2014 Posted January 13, 2014 This workflow is officially deprecated in favour of Thumbnail Navigation List the contents of directories, ordered by add or modified date. rda sorts from the most recently added and rdz does the reverse; rdn sorts from the most recently modified and rdo does the reverse. The list is auto-refreshed, making for a good way to track changes. To act on the selections, use the standard Alfred shortcuts. You can activate file actions, dive into directories, preview files, reveal in Finder, add to the file buffer… By default the Workflow searches in ~/Desktop and ~/Downloads. Change the value in the directories Workflow Environment Variable to use different paths, separated by commas. JacobMiller, FroZen_X, Sridhar Katakam and 4 others 6 1
cands Posted January 19, 2014 Posted January 19, 2014 (edited) I find this to be a very useful workflow, thanks! A minor issue for me is that after I run rdn or rdo some applications with names matching the command (e.g. "Remote Desktop Connection") show first in the list, above the files in the Downloads directory. Is this possible to fix? Edited January 19, 2014 by cands
vitor Posted January 19, 2014 Author Posted January 19, 2014 Yes, you can simply go to the workflow (via Alfred’s preferences), and change the keywords (you just have to double-click each Script Filter node and change the top line, to something that will not interfere with your other apps. JacobMiller 1
cands Posted January 19, 2014 Posted January 19, 2014 Thanks, using other keywords solved the problem (I realize that it may not be possible to only show the results output from the workflow after invoking the commands)!
vitor Posted October 5, 2016 Author Posted October 5, 2016 Update. It now uses OneUpdater, so this should be the last time you need to manually update.
vitor Posted April 12, 2017 Author Posted April 12, 2017 Update. New icon. To update, download the latest version (same URL) or wait a few days (15 or less) and it’ll prompt you to on next usage, since it uses OneUpdater.
Jasondm007 Posted October 7, 2017 Posted October 7, 2017 @vitor - I love this workflow! Thanks for sharing!! Out of curiosity, is there any way to sort by the date added field? Thanks for your help!
vitor Posted October 7, 2017 Author Posted October 7, 2017 2 hours ago, Jasondm007 said: @vitor - I love this workflow! Thanks for sharing!! Thank you. Glad you find it useful. 2 hours ago, Jasondm007 said: Out of curiosity, is there any way to sort by the date added field? There is, but I do not intend to add it to the Workflow. This Ask Different answer and this blog post should put you on the right track.
Jasondm007 Posted October 7, 2017 Posted October 7, 2017 Thanks for the suggested materials concerning how I might implement having the workflow sort the download folder's contents by the date it was added. After looking through everything, I'm afraid they're pretty far past my limited skillset. Thanks for your help though!!
vitor Posted October 7, 2017 Author Posted October 7, 2017 17 minutes ago, Jasondm007 said: After looking through everything, I'm afraid they're pretty far past my limited skillset. There you go. Added the two extra options for you. JacobMiller 1
Jasondm007 Posted October 7, 2017 Posted October 7, 2017 @vitor You're the best! This is fantastic!! Thanks a ton!
politicus Posted October 13, 2017 Posted October 13, 2017 @vitor One more very useful workflow! Thank you! Is is possible to hide not completed Downloads from the search results?
vitor Posted October 13, 2017 Author Posted October 13, 2017 4 hours ago, politicus said: Is is possible to hide not completed Downloads from the search results? Would have to look into it. But I’m not going to add it to the Workflow because seeing incomplete Downloads is useful (e.g. if you cancel a download and want to delete the incomplete file). politicus 1
deanishe Posted October 13, 2017 Posted October 13, 2017 On 08/10/2017 at 1:57 AM, Jasondm007 said: how I might implement having the workflow sort the download folder's contents by the date it was added. The date added is stored in the Spotlight metadata, so you’d have to use something like mdls to retrieve it.
vitor Posted October 13, 2017 Author Posted October 13, 2017 1 hour ago, deanishe said: The date added is stored in the Spotlight metadata, so you’d have to use something like mdls to retrieve it. Yes, that’s the solution I used.
deanishe Posted October 16, 2017 Posted October 16, 2017 On 13/10/2017 at 6:36 PM, vitor said: Yes, that’s the solution I used. That explains why it's way slower than the other variants. How about turning on "Alfred filters results" for that one? Also, I'm seeing the following error for all commands (although they all still seem to work): Code 2: /bin/bash: -c: line 13: syntax error near unexpected token `fi' /bin/bash: -c: line 13: `fi'
vitor Posted October 16, 2017 Author Posted October 16, 2017 (edited) 1 hour ago, deanishe said: Also, I'm seeing the following error for all commands (although they all still seem to work): Fixed that. Thank you. 1 hour ago, deanishe said: That explains why it's way slower than the other variants. How about turning on "Alfred filters results" for that one? The solution itself is pretty hacky. Wasn’t thinking of officially adding it to the Workflow. Conceptually, Downloads should be a directory where other apps put files and then we only take them out. I also wouldn’t like the inconsistency: the current solution starts the search from anywhere on the string, including the middle of words. I find that somewhat important for downloaded stuff (where much/most of the time you don’t control the filename as it comes). Since that’s not something Alfred can currently do by itself, the two solutions would be inconsistent with each other. This Workflow should be pretty safe to edit, though. It’s unlikely it’ll need further updates apart from the just released fix (it even still uses the XML Script Filter and is largely unchanged from its origins). Edited October 16, 2017 by vitor
deanishe Posted October 16, 2017 Posted October 16, 2017 1 hour ago, vitor said: Conceptually, Downloads should be a directory where other apps put files and then we only take them out. I tend to leave quite a lot of stuff in ~/Downloads that doesn't have an obvious other place to be, so I always want most-recently added at the top, not most-recently accessed. 1 hour ago, vitor said: the current solution starts the search from anywhere on the string, including the middle of words Good point. That is preferable behaviour. 1 hour ago, vitor said: This Workflow should be pretty safe to edit, though Given the above, I think I'll whip up my own that caches the times. I'm not a fan of bash and/or perl.
Jasondm007 Posted November 8, 2017 Posted November 8, 2017 @vitor A few weeks ago, in this thread, you were nice enough to update this great workflow, adding the options to sort by the date added. More specifically, you added two options: one placing the newest item first, and another placing the oldest item first. To jog your memory I've added the script from the filter below (for the second option - file with the oldest date added is listed first). IFS=$'\n' files=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "${HOME}/Downloads/"* | xargs -0 -I {} echo {} | sed 'N;s/\n/ /' | sort | cut -d ' ' -f 4- | grep --ignore-case ".*{query}.*" | perl -MHTML::Entities -CS -pe'$_ = encode_entities($_, q{&<>"'\''})') echo "<?xml version='1.0'?><items>" for file in ${files}; do echo "<item uuid='file' arg='${file}' type='file'>" echo "<title>$(basename ${file})</title>" echo "<subtitle>${file}</subtitle>" echo "<icon type='fileicon'>${file}</icon>" echo "</item>" done echo "</items>" fi While the query works great - as it pulls the items up in their proper order - unfortunately, they're not clickable. When I press return on the file that I'd like to open, the files never actually open. In addition, all of the icons/thumbnails in the query just look like white (see image below). Any ideas for how I might amend your code above to operate like usual? As always, thanks a ton for all of your help!
vitor Posted November 9, 2017 Author Posted November 9, 2017 @Jasondm007 Upload the Workflow somewhere so I can check.
Jasondm007 Posted November 9, 2017 Posted November 9, 2017 @vitor Sure - my apologies. Here's a link to the present workflow: https://drive.google.com/file/d/1_9nCeNVudhnzEwS2u7ATyxnABtOyvz0e/view?usp=sharing Thanks for your help!
vitor Posted November 9, 2017 Author Posted November 9, 2017 Fixed. For reference: IFS=$'\n' files=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "${HOME}/Downloads/"* | xargs -0 -I {} echo {} | sed 'N;s/\n/ /' | sort | cut -d ' ' -f 4- | grep --ignore-case ".*{query}.*" | perl -MHTML::Entities -CS -pe'$_ = encode_entities($_, q{&<>"'\''})') echo "<?xml version='1.0'?><items>" for file in ${files}; do file="${HOME}/Downloads/${file}" echo "<item uuid='file' arg='${file}' type='file'>" echo "<title>$(basename ${file})</title>" echo "<subtitle>${file}</subtitle>" echo "<icon type='fileicon'>${file}</icon>" echo "</item>" done echo "</items>" fi
Jasondm007 Posted November 9, 2017 Posted November 9, 2017 Thanks a ton @vitor !! It works perfectly!!
Jasondm007 Posted November 9, 2017 Posted November 9, 2017 Last question, @vitor , I promise! For those of us without coding backgrounds, do you have any favorite resources that you'd recommend to others interested in tweaking the RecentDownloads workflow? More specifically, I'd like to learn how to use some of the other spotlight metadata to restrict the output further, but - as a newbie - I'm not exactly sure where to start with some of these things. For example, if wanted to restrict the output to certain file types, it looks like using the kMDItemKind field might be a good way of doing that. However, I don't have enough understanding of how your script is using these elements to provide the output (i.e., and this is a "ME" problem and nothing with the script). I've tried adding these elements, but it's clearly not working ... and I don't know enough to efficiently problem shoot. In any event, I'd just like to learn how to some of these metadata elements without bothering you and other equally nice people in the Alfred community. Thanks for your help!
vitor Posted November 9, 2017 Author Posted November 9, 2017 @Jasondm007 I haven’t used it but it’s allegedly good — Bash Academy. Learning Bash will go a long way towards understanding the terminal and how to script. Bash is a glue language where you leverage other tools in your system, so you can usually do a lot of different things with little code.
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