Windows – Batch file to move files created daily to a specific month folder

batch filewindows 7

Files get placed in a directory daily: myfile11515, myfile1243, myfileABC

Need to move them to a different directory on the same computer that has the month folders:

January
February
March
etc.

I want it to read the created on date of the file to determine which month folder to put the file in.

The tricky part is that I want this to run and put the daily files in the month folder each month WITHOUT ever having to edit the batch file. So, some way to read the created by date each month.

Best Answer

Make subdirectories named 01 through 12 under the source directory where the files land.

Make symlinks using MKLINK a la

MKLINK /D "C:\Users\<yourusername>\Documents\Monthlies\01" "M:\January"

then harvest today's date ith

FOR /F “TOKENS=1,2 eol=/ DELIMS=/ ” %%A IN (‘DATE/T’) DO SET mm=%%B

then copy the files in question from the source to C:\Users\\Documents\Monthlies\%%B which will also appear as M:\January .

Related Question