# Note that this is also just a quick scribble and you may need to adapt this to your needs # Folders dir /b /s /a:d | perl -ne "print $_ if $_=~/^c:\\myinputpath\\.*?\\myfolder\\.*?$/" > filesconfig.txt # Files dir /b /s | perl -ne "print $_ if $_=~/^c:\\myinputpath\\.*?\\myfolder\\filenames.*?$/" > foldersconfig.txt