Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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  
+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
add comment

1 Answer

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

$dir="Q:\Test";
$categories="Q:\categories.txt";
$cats=@{};

get-childitem $dir -recurse | %{

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

$cats.GetEnumerator() | %{

    echo $_.Key >> $categories;
}

Example: Files:

   David_Eddings-The_Mallorean.epub
   Jan_Myrdal-Confessions_of_a_disloyal_european.txt
   George_Orwell-Homage_to_Catalonia.mobi

Would result in the following categories:

   David_Eddings
   Jan_Myrdal
   George_Orwell

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

share|improve this answer
add comment

Your Answer

 
discard

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.