Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 a lot of (i.e., more than 10 000) documents on my PC that I want to organize in several Categories, based on their filenames. Most of the files have descriptive filenames such that they can be easily categorized solely on their names.

I thought of building an index of the words that appear in the filenames (yet, I don't know how to achieve this), then going through the index and choosing the most relevant words (this will be done manually) which will become the Category names for my files. Then, I want to automatically create folders based on these Category names and move the files (automatically) in these folders. When a file belongs to several Categories, I want to create NTFS HardLinks (rather than copy each file multiple times).

I use Windows 7. Do you know how I can best achieve this task?

I thought of using Everything (which can instantly display a list of all the files that have a given word in their filenames), but the major problem is that of getting the Category names (since first I need a list of all the words that appear in the filenames).

share|improve this question
+1 interested to see what comes up in answers. you could probably achieve this in powershell by utilising 'Get-ChildItem -recurse' and then using a ForEach to pipe the files returned. much better if there's something that already does this though. – James Jun 2 '13 at 21:36
Could you post a couple of example filenames, so we can see the naming pattern. – Martin Jun 2 '13 at 21:52
@Martin: Many are books, others are research articles. Usually, the title contains the author, its initials, the title of the book or article. Some filename contain _ instead of 'space'. – digital-Ink Jun 2 '13 at 22:05

Short PowerShell script that lists all the filenames that match "category_name-anyText.anyExtension".:


get-childitem $dir -recurse | %{

    if(-not $file.PSIsContainer)
        if( $file.BaseName -match "^([a-z0-9]+)[-]+.*$")
            if( -not $cats.ContainsKey($matches[1]))
                $cats.add($matches[1], [int]1);
                $val=$cats.Get_Item($matches[1]) + 1;
                $cats.Set_Item($matches[1], $val);

$cats.GetEnumerator() | %{

    echo $_.Key >> $categories;

Example: Files:


Would result in the following categories:


This is the regex that matches filenames: "^([a-z0-9]+)[-]+.*$", this would have to be adjusted to match different categories.

share|improve this answer

Your Answer


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.