Having very little experience with Batchfiles, scripting and generally "coding", I quickly ran into a problem with a Batch I want to create.
The situation is as follows:
I have a folder, in which *.txt files are automatically inserted, and I wanted to move these files to different folders based on the names the files have. I did this with Robocopy and it works just fine. Then I discovered the possibility to log the stuff that Robocopy does. The Batch currently looks like this:
robocopy C:\Source C:\Target_Normal file*.txt /xf file022*.txt /mov /log+:LogNo.txt /ns /nc /np /r:1 /w:5
robocopy C:\Source C:\Target_Special file022*.txt /mov /log+:LogNo.txt /ns /nc /np /r:1 /w:3
This Batch has to be part of a Windows Scheduled Task, that has to run every Minute. Because there are a lot of files to be moved, the logfile will soon be very bloated. I now need a Logfile for every day, that the same Batch automatically creates the first time it runs on a new day. It would be perfect if the name of the newly created Logfile contained the Date it was created, of course. I want to put all of this above the robocopy lines. In pseudocode, I'd like to have something like this:
If currentDay has no Logfile yet ->
Create Logfile with Name Log+currentDate ->
else (nothing and continue?)
...if that makes any sense. I just don't know how to express that to work in a Batch.
This batch demonstrates how to get the actual date with wmi and it splits that ISO date time into parts you can assemble to your liking.