librelist archives

« back to archive

simple archive script

simple archive script

From:
Ron DuPlain
Date:
2010-03-09 @ 17:25
I regularly run into an issue where I keep files around, which really
aren't that important, but I don't want to delete.  My download
directory has hundreds of files in it.  I started experimenting with a
script which puts files in $HOME/doc/archive renaming the file with
the current date/time.

http://github.com/rduplain/home/blob/master/bin/archive

$ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
mv 'Some Crazy Doc.pdf' /home/rduplain/doc/archive/20100309_122238.635075459.pdf
mv lolcats.flv /home/rduplain/doc/archive/20100309_122238.654437698.flv
mv thoughts.txt /home/rduplain/doc/archive/20100309_122238.672766914.txt
mv Mr-A-File.txt /home/rduplain/doc/archive/20100309_122238.694994880.txt
$ ls -1t $HOME/doc/archive | head -4
20100309_122238.635075459.pdf
20100309_122238.654437698.flv
20100309_122238.672766914.txt
20100309_122238.694994880.txt
$

What do you think?

Ron

Re: [cville] simple archive script

From:
Kai Groner
Date:
2010-03-09 @ 18:04
On Tue, Mar 9, 2010 at 12:25 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>
> I regularly run into an issue where I keep files around, which really
> aren't that important, but I don't want to delete.  My download
> directory has hundreds of files in it.  I started experimenting with a
> script which puts files in $HOME/doc/archive renaming the file with
> the current date/time.
>
> http://github.com/rduplain/home/blob/master/bin/archive
>
> $ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
> mv 'Some Crazy Doc.pdf' /home/rduplain/doc/archive/20100309_122238.635075459.pdf
> ...

I've thought about doing this myself, but I think I would need some
sort of metadata store to be able to find things again.  I've looked
at projects like tracker and beagle, but that's as far as I've gotten.

I'm not sure if there are any general filesystem metadata frameworks
that have gained traction, so far.  Anyone care to comment on Apple's
Spotlight or other systems?


Kai

Re: [cville] simple archive script

From:
Ryan Ahearn
Date:
2010-03-09 @ 17:42
Why the decision to completely drop the name of the original file? I think
moving a bunch of videos to date_time.flv would be as good as deleting them
for me.

-Ryan


On Tue, Mar 9, 2010 at 12:25 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:

> I regularly run into an issue where I keep files around, which really
> aren't that important, but I don't want to delete.  My download
> directory has hundreds of files in it.  I started experimenting with a
> script which puts files in $HOME/doc/archive renaming the file with
> the current date/time.
>
> http://github.com/rduplain/home/blob/master/bin/archive
>
> $ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
> mv 'Some Crazy Doc.pdf'
> /home/rduplain/doc/archive/20100309_122238.635075459.pdf
> mv lolcats.flv /home/rduplain/doc/archive/20100309_122238.654437698.flv
> mv thoughts.txt /home/rduplain/doc/archive/20100309_122238.672766914.txt
> mv Mr-A-File.txt /home/rduplain/doc/archive/20100309_122238.694994880.txt
> $ ls -1t $HOME/doc/archive | head -4
> 20100309_122238.635075459.pdf
> 20100309_122238.654437698.flv
> 20100309_122238.672766914.txt
> 20100309_122238.694994880.txt
> $
>
> What do you think?
>
> Ron
>

Re: [cville] simple archive script

From:
Ron DuPlain
Date:
2010-03-09 @ 19:40
On Tue, Mar 9, 2010 at 12:42 PM, Ryan Ahearn <ryan.c.ahearn@gmail.com> wrote:
> Why the decision to completely drop the name of the original file? I think
> moving a bunch of videos to date_time.flv would be as good as deleting them
> for me.
>

My intended use is for scratch text files and downloaded files which
collect dust in $HOME/download.  These are primarily txt, jpg/png, pdf
files which have random names, e.g. psp9651047.pdf.[1]  I think a
datetime is more useful than random characters.

I plan on using grep for txt, acroread's directory find feature for
pdf, and an image viewer for jpg.

I find myself dumping notes into text files all the time, just to get
ideas out, without any sensible file names (tmp.txt, scratch.txt).  I
think it would also be useful for snippets of code where I'm playing
with bash, ruby, python, ... `grep 'import this' *.py`. The filename
in grep's results tells me when I was trying something.

Looking for a simple recipe,

Ron


[1]: via http://twitter.com/yellowfish_md/status/10060378579


> On Tue, Mar 9, 2010 at 12:25 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>>
>> I regularly run into an issue where I keep files around, which really
>> aren't that important, but I don't want to delete.  My download
>> directory has hundreds of files in it.  I started experimenting with a
>> script which puts files in $HOME/doc/archive renaming the file with
>> the current date/time.
>>
>> http://github.com/rduplain/home/blob/master/bin/archive
>>
>> $ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
>> mv 'Some Crazy Doc.pdf'
>> /home/rduplain/doc/archive/20100309_122238.635075459.pdf
>> mv lolcats.flv /home/rduplain/doc/archive/20100309_122238.654437698.flv
>> mv thoughts.txt /home/rduplain/doc/archive/20100309_122238.672766914.txt
>> mv Mr-A-File.txt /home/rduplain/doc/archive/20100309_122238.694994880.txt
>> $ ls -1t $HOME/doc/archive | head -4
>> 20100309_122238.635075459.pdf
>> 20100309_122238.654437698.flv
>> 20100309_122238.672766914.txt
>> 20100309_122238.694994880.txt
>> $
>>
>> What do you think?
>>
>> Ron
>
>

Re: [cville] simple archive script

From:
Matt Dawson
Date:
2010-03-09 @ 19:59
I was about to agree with Ryan, but your use case makes sense. I tend
to be really, really anal with file management on my machines, so I'd
have to be in a unique situation to make use of this.

I probably *do* lose a lot of scratch work in the process - that's the
danger of being a compulsive spring-cleaner.

Kai: Spotlight is great - except when it's not. For certain things,
it's remarkably quick and accurate. I've used it to look up
function/class names system-wide and am often surprised with its
speed. However, I'll often type in some random search string and get a
list of hundreds of documents with no good indication as to why
they're all included.

Matt

On Tue, Mar 9, 2010 at 2:40 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
> On Tue, Mar 9, 2010 at 12:42 PM, Ryan Ahearn <ryan.c.ahearn@gmail.com> wrote:
>> Why the decision to completely drop the name of the original file? I think
>> moving a bunch of videos to date_time.flv would be as good as deleting them
>> for me.
>>
>
> My intended use is for scratch text files and downloaded files which
> collect dust in $HOME/download.  These are primarily txt, jpg/png, pdf
> files which have random names, e.g. psp9651047.pdf.[1]  I think a
> datetime is more useful than random characters.
>
> I plan on using grep for txt, acroread's directory find feature for
> pdf, and an image viewer for jpg.
>
> I find myself dumping notes into text files all the time, just to get
> ideas out, without any sensible file names (tmp.txt, scratch.txt).  I
> think it would also be useful for snippets of code where I'm playing
> with bash, ruby, python, ... `grep 'import this' *.py`. The filename
> in grep's results tells me when I was trying something.
>
> Looking for a simple recipe,
>
> Ron
>
>
> [1]: via http://twitter.com/yellowfish_md/status/10060378579
>
>
>> On Tue, Mar 9, 2010 at 12:25 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>>>
>>> I regularly run into an issue where I keep files around, which really
>>> aren't that important, but I don't want to delete.  My download
>>> directory has hundreds of files in it.  I started experimenting with a
>>> script which puts files in $HOME/doc/archive renaming the file with
>>> the current date/time.
>>>
>>> http://github.com/rduplain/home/blob/master/bin/archive
>>>
>>> $ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
>>> mv 'Some Crazy Doc.pdf'
>>> /home/rduplain/doc/archive/20100309_122238.635075459.pdf
>>> mv lolcats.flv /home/rduplain/doc/archive/20100309_122238.654437698.flv
>>> mv thoughts.txt /home/rduplain/doc/archive/20100309_122238.672766914.txt
>>> mv Mr-A-File.txt /home/rduplain/doc/archive/20100309_122238.694994880.txt
>>> $ ls -1t $HOME/doc/archive | head -4
>>> 20100309_122238.635075459.pdf
>>> 20100309_122238.654437698.flv
>>> 20100309_122238.672766914.txt
>>> 20100309_122238.694994880.txt
>>> $
>>>
>>> What do you think?
>>>
>>> Ron
>>
>>
>

Re: [cville] simple archive script

From:
Ron DuPlain
Date:
2010-03-09 @ 21:51
I updated the script based on feedback (some of us are in #cville on
freenode IRC, woot).
http://github.com/rduplain/home/blob/master/bin/archive

Now the script preserves the original filename, and puts files into a
directory structure with the time.  You can configure the script with
environment variables.

 * ARCHIVE_HOME defaults to $HOME/doc/archive
 * ARCHIVE_DATE_FORMAT defaults to %Y/%m/%d/%H%M%S
 * (see man date for date formats)

archive accepts all mv command line switches.  This is useful when you
have the date format set to %Y/%m/%d, where you can call `archive -i
filename` to prompt you if you already have filename in 2010/03/09,
just like mv -i.

Example:

$ archive file*.txt
`file1.txt' -> `/home/rduplain/doc/archive/2010/03/09/164228/file1.txt'
`file2.txt' -> `/home/rduplain/doc/archive/2010/03/09/164228/file2.txt'
`file3.txt' -> `/home/rduplain/doc/archive/2010/03/09/164228/file3.txt'
$ find doc/archive/
doc/archive/
doc/archive/2010
doc/archive/2010/03
doc/archive/2010/03/09
doc/archive/2010/03/09/164228
doc/archive/2010/03/09/164228/file3.txt
doc/archive/2010/03/09/164228/file1.txt
doc/archive/2010/03/09/164228/file2.txt

-Ron


On Tue, Mar 9, 2010 at 2:59 PM, Matt Dawson <matthewtdawson@gmail.com> wrote:
> I was about to agree with Ryan, but your use case makes sense. I tend
> to be really, really anal with file management on my machines, so I'd
> have to be in a unique situation to make use of this.
>
> I probably *do* lose a lot of scratch work in the process - that's the
> danger of being a compulsive spring-cleaner.
>
> Kai: Spotlight is great - except when it's not. For certain things,
> it's remarkably quick and accurate. I've used it to look up
> function/class names system-wide and am often surprised with its
> speed. However, I'll often type in some random search string and get a
> list of hundreds of documents with no good indication as to why
> they're all included.
>
> Matt
>
> On Tue, Mar 9, 2010 at 2:40 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>> On Tue, Mar 9, 2010 at 12:42 PM, Ryan Ahearn <ryan.c.ahearn@gmail.com> wrote:
>>> Why the decision to completely drop the name of the original file? I think
>>> moving a bunch of videos to date_time.flv would be as good as deleting them
>>> for me.
>>>
>>
>> My intended use is for scratch text files and downloaded files which
>> collect dust in $HOME/download.  These are primarily txt, jpg/png, pdf
>> files which have random names, e.g. psp9651047.pdf.[1]  I think a
>> datetime is more useful than random characters.
>>
>> I plan on using grep for txt, acroread's directory find feature for
>> pdf, and an image viewer for jpg.
>>
>> I find myself dumping notes into text files all the time, just to get
>> ideas out, without any sensible file names (tmp.txt, scratch.txt).  I
>> think it would also be useful for snippets of code where I'm playing
>> with bash, ruby, python, ... `grep 'import this' *.py`. The filename
>> in grep's results tells me when I was trying something.
>>
>> Looking for a simple recipe,
>>
>> Ron
>>
>>
>> [1]: via http://twitter.com/yellowfish_md/status/10060378579
>>
>>
>>> On Tue, Mar 9, 2010 at 12:25 PM, Ron DuPlain <ron.duplain@gmail.com> wrote:
>>>>
>>>> I regularly run into an issue where I keep files around, which really
>>>> aren't that important, but I don't want to delete.  My download
>>>> directory has hundreds of files in it.  I started experimenting with a
>>>> script which puts files in $HOME/doc/archive renaming the file with
>>>> the current date/time.
>>>>
>>>> http://github.com/rduplain/home/blob/master/bin/archive
>>>>
>>>> $ archive Some\ Crazy\ Doc.pdf lolcats.flv thoughts.txt Mr-A-File.txt
>>>> mv 'Some Crazy Doc.pdf'
>>>> /home/rduplain/doc/archive/20100309_122238.635075459.pdf
>>>> mv lolcats.flv /home/rduplain/doc/archive/20100309_122238.654437698.flv
>>>> mv thoughts.txt /home/rduplain/doc/archive/20100309_122238.672766914.txt
>>>> mv Mr-A-File.txt /home/rduplain/doc/archive/20100309_122238.694994880.txt
>>>> $ ls -1t $HOME/doc/archive | head -4
>>>> 20100309_122238.635075459.pdf
>>>> 20100309_122238.654437698.flv
>>>> 20100309_122238.672766914.txt
>>>> 20100309_122238.694994880.txt
>>>> $
>>>>
>>>> What do you think?
>>>>
>>>> Ron
>>>
>>>
>>
>