Thousands of images, date based directory structure - how?

1

I have thousands of images dumped into one big directory. Most images have an file name according to YYYY-MM-DD-misc-keyword.ext. I would now like to create a directory structure where each directory has a name according to YYYY-MM, basically one dir. per month of the year. Obviously, i would like to move imags into their corresponding directory by using the info in the file name.

Is there a automated way of using this with windows xp? I.e. (1) create dir. structure and (2) move images to right directory?

NeverTheMynd

Posted 2009-12-30T22:08:59.520

Reputation:

Answers

0

You might also try belvedere from a Lifehacker writer. You can create rules and an automatic "move file" action. Might not be powerful enough for your needs.

alt text

outsideblasts

Posted 2009-12-30T22:08:59.520

Reputation: 6 297

1

As Rohit Nair suggests, there won't be a standard command to do it, but there are multiple tools that can be used to do it. My tool of choice would probably be Perl - but Python would also handle it without any trouble. And any competent shell should too; Cygwin and Bash, for example, and probably Powershell too (though I have no experience with it).

#!/bin/perl -w

for my $file (glob '????-??-??.*')
{
    my $dir = $file;
    $dir =~ s/-\d\d\..*//;
    mkdir $dir unless -d $dir;
    rename $file, "$dir/$file";
}

You can refine the glob expression if you want to, using '[0-9]' in place of each question mark. Beware spaces in names - see bsd_glob

Jonathan Leffler

Posted 2009-12-30T22:08:59.520

Reputation: 4 526

0

Without a fully automated solution, I think Everything search might be of use. It's a very fast and effective file name and folder searcher. If you search for "2004-11", you'll see all the files with that as part of the name, and can simply cut and paste into a particular folder.

Depends on how many different months you have of course, maybe it's enough to be worthwhile writing/learning how to write a script, but if it's not too many then try Everything.

outsideblasts

Posted 2009-12-30T22:08:59.520

Reputation: 6 297