thoughts on sorting files into sub-folders by access date?

RW rwmaillists at googlemail.com
Thu Jul 1 21:09:03 UTC 2010


On Thu, 1 Jul 2010 10:20:25 -0700
Steve Franks <bahamasfranks at gmail.com> wrote:

> Hi y'all,
> 
> My high-end point&shoot camera likes to glob all my photos in a single
> folder, and it's glutting up my drive, and makes finding a specific
> trip unpleasant, with no good place for metadata.  My SLR sorts them
> into folders by date, which I love.
> 
> ...
> I thought I'd check if there's some trivially simple way of doing this
> with bash & find first.
> 

If the timestamps are acccurate you could simply loop around the files
and do something like this (untested):

dir="${targetdir}/`stat -f %Sm -t %Y%m%d ${file}`/"
[ -d "${dir}"] || mkdir "${dir}"
mv "${file}" "${dir}"]



More information about the freebsd-hackers mailing list