Prepend downloaded file names, date & time to a txt file

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

I originally asked how to do this in the forum, but managed to figure it out myself.

I wanted to list files that had been downloaded on a different computer to a text file (that syncs via Dropbox so I could check them on a notes app on my iPhone/iPad), prepending them at the top like the following:

2013-08-19 10:25:11 AM
Archive 01.dmg

2013-08-18 7:32:23 PM

2013-08-17 8:56:42 AM

Here's the shell script I used:
Code: Select all

cat ~/Dropbox/Sync/Notes/Downloaded\ Files.txt | pbcopy && echo -e "`date +'%Y-%m-%d %r'`""\n""${filename##*/}""\n""-----------------------------" "\n" > ~/Dropbox/Sync/Notes/Downloaded\ Files.txt && pbpaste >> ~/Dropbox/Sync/Notes/Downloaded\ Files.txt

I don't know shell scripting, I just managed to cobble this together from looking at other examples. So if anyone wants to clean it up or improve it that would be great.
Posts: 26
Joined: Wed May 09, 2012 5:52 am
Location: UK

Return to Tips & Tricks - DO NOT POST QUESTIONS