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.