Select and move files by mask with Windows command line
During previous 5 years I have downloaded files from FTP server. Those were texts and images, that had been downloaded from FTP resources. During these 5 years its quantity became enormous – over 150 000 items in each folder. It worked automatically, that's why I hadn't paid attention to disc size and quantity of files. But once the space decreased too much.
So, I decided to move files to folders by year creation. It's good that all files had the year number in filenames. Have you ever tried to open the Explorer with 150k files? It's not a good idea.
The task of moving files could be easily solved with PowerShell, but I had Windows server 2003(!). And all I had was command line. To tell the truth, I have already forgotten CMD commands. But something is still in my mind 🙂
After some experiments, the solution was created. It was a CMD file that created a directory and moved files to folders.
FORFILES /P C:\News\agency\mydir /S /M *2013*.* /C "cmd /c move @file C:\News\agency\mydir\2013\"
Create CMD file with this content and execute it from command line.