I have a folder with more than a hundred thousand (100,000+) pdf files generated by a script that need to be moved to multiple folders based on the file name. The pdf files are all named like this: YY-nnnnn.pdf
where YY is the year and nnnnn is the file sequence within a year, like this:
00-00001.pdf
00-00002.pdf
00-00003.pdf
Each year contains about 25,000 files. I have generated the files for four years, I still have 6 years worth of pdfs to be generated.
I need to move these files to the server. The server has the following folder structure:
D:.
├───00-00000
├───00-01000
├───00-02000
├───00-03000
├───00-04000
├───00-05000
├───00-06000
├───00-07000
├───00-08000
├───00-09000
├───00-10000
├───00-11000
Each year can have up to YY-25000
folders. The files need to go each into their own folder based on the first five characters, like this:
├───00-00000
│ 00-00001.pdf
│ 00-00002.pdf
│ 00-00003.pdf
│ 00-00004.pdf
...
│ 00-00997.pdf
│ 00-00998.pdf
│ 00-00999.pdf
│
├───00-01000
│ 00-01000.pdf
│ 00-01001.pdf
│ 00-01002.pdf
I was thinking of using the RoboCopy
utility but could not figure out how to script it correctly. Perhaps a small script will be required.