Get a file's emblem from command line?
I'd like to be able to determine what emblem a file has from the command line. Is there a way to determine this? Also, is there a way to apply emblems from the command line?
I usually have a cron job that trashes files over 7 days old in my ~/Downloads, but I'd like to be able to only delete files that don't have a particular emblem (my seeding torrents). I've been applying these emblems manually, but if I can automate that as well, that'd be awesome.
My usual cron job is just a simple find command:
find /home/zach/Downloads/ -ctime +7 -exec trash {} \;
Edit:
I solved my own question.
Bonus:
To elaborate on exactly what I'm doing, I use deluge-torrent
to manage my downloads. I am now using the execute plugin to run this script on torrent complete:
#!/usr/bin/env bash
# deluge gives the download directory name as the third argument
gvfs-set-attribute -t stringv "$3" metadata::emblems ubuntuone-unsynchronized
I then created my trasher.sh
(this requires the trash-cli
package):
#!/usr/bin/env bash
[[ "$(gvfs-info -a metadata::emblems $*)" =~ "ubuntuone-unsynchronized" ]] || trash "$*"
Now, I just modify my cron to:
find /home/zach/Downloads/ -maxdepth 1 -ctime +7 -exec /home/zach/Scripts/trasher.sh {} \;
And voila! Now Deluge can manage its downloads, while my cleanup script can safely cleanup old files without interfering with seeding torrents.
<Juhaz>
in ##gnome on freenode got it.
gvfs-info -a metadata::emblems FOLDER
will retrieve the emblem of a folder/file and
gvfs-set-attribute -t stringv FOLDER metadata::emblems EMBLEM
will allow you to set emblem of the folder/file.