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

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
app_update.pkg
------------------------—--
2013-08-17 8:56:42 AM
Wallpapers.zip
------------------------—--
Here's the shell script I used:
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.
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
app_update.pkg
------------------------—--
2013-08-17 8:56:42 AM
Wallpapers.zip
------------------------—--
Here's the shell script I used:
- Code: Select all
filename=$1
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.