Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
3  
What a good idea! :) –  invert Sep 1 '10 at 8:40
add comment

2 Answers

up vote 7 down vote accepted

<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.

share|improve this answer
3  
And metadata is stored on ~/home/.local/share/gvfs-metadata. There is one file per partition/volumen if I understand it right. Binary files. Ugly is you ask me, but likely faster than xml files. –  Javier Rivera Sep 1 '10 at 15:15
    
Thats where they first pointed me to when I asked in ##gnome. Lots of binary .log files. I made the mistake of cat *'ing the dir. It also seems that the files there never get cleaned out? –  aperson Sep 1 '10 at 15:44
    
+1 aperson. You beat me to it and you should mark this answer as correct. –  Richard Holloway Sep 1 '10 at 15:48
1  
Doesn't work on 12.04. –  fossilet Jul 1 '12 at 13:38
add comment

This post explains how emblem information is stored in a XML file under ~/.nautilus/metafiles. First you'd need to test if the XML related to each download exists, and if so, whether it contains the emblem of your choice.

share|improve this answer
2  
My ~/.nautilus/ folder is 100% empty... –  fluteflute Sep 1 '10 at 9:18
3  
Old info, this was changed on Lucid. And BTW I will also love to know where does nautilus store them now. –  Javier Rivera Sep 1 '10 at 11:13
    
Yeah, I already read that post (sorry, should have specified). But as others have commented, that information is no longer relevant. I even tried searching for .xml files in my ~ and nothing came up other than some things for other programs. –  aperson Sep 1 '10 at 13:01
    
Thanks for pointing that out @javier, sorry for that! –  invert Sep 10 '10 at 7:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.