I need to create a for next loop that will do the following.
We have predefined variables on our Server for HPMONTH, HPYEAR for example,
HPMONTH can be 01 - 12 for January through December
HPYEAR is in the format (for this year) 2018
I need to copy reports each month to folders that have the month in name (i.e. January - December) so the HPMONTH which is a number needs to be put into another variable like (MONTH) so that Jan is 01, Feb is 02, etc.
01 January Monthend Production for 2018
02 February Monthend Production for 2018
We have a PREFIX on the folder names for 01, 02, 03 only so that when the folder names are sorted, they use that number to sort because otherwise January will not be first if you know what I mean. The for next loop only needs to assign to the variable MONTH so that when HPMONTH is 01, the variable MONTH will be assigned the name JANUARY, for February, the HPMONTH has the number 02 so then the for next loop should assign to the variable MONTH, the name FEBRUARY, etc. Not hard but have never done it myself.
Brian
For next loop
Moderator: DosItHelp
Re: For next loop
Your description is missing some details (where to find the files to copy, where to copy to, so i assume all could be found in the actual directory), so the following might help you:
penpen
Code: Select all
@for %%a in ("*") do @for /d %%b in ("%HPMONTH%*") do @copy "%%~a" "%%~b"