Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 0 down vote accepted

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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

You must log in to answer this question.