 <p>Here is a commented batch code for this task:</p> <pre><code>@echo off setlocal rem Define source and backup path. set "SourcePath=C:\machines\models" set "BackupPath=E:\backup" rem Get current date in format YYYY-MM-DD independent on local date format. for /F "skip=1 tokens=1 delims=." %%T in ('%SystemRoot%\System32\wbem\wmic.exe OS get localdatetime') do set LocalDateTime=%%T set "YearMonthDay=%LocalDateTime:~0,4%-%LocalDateTime:~4,2%-%LocalDateTime:~6,2% rem For each subfolder in source path check if there is a subfolder "defects". rem If subfolder "defects" exists, copy all files and subfolders of "defects" rem to the appropriate backup directory with current date and subfolder name rem in source folder path. Then remove the subfolder "defects" in source rem folder even if being completely empty to avoid processing this folder rem again when not being recreated again in the meantime. for /D %%# in ("%SourcePath%\*") do ( if exist "%%#\defects\*" ( %SystemRoot%\System32\xcopy.exe "%%#\defects\*" "%BackupPath%\%YearMonthDay%\%%~nx#_defects\" /H /I /K /Q /R /S /Y &gt;nul rd /Q /S "%%#\defects" ) ) endlocal </code></pre> <p>Run once in command prompt window <code>wmic OS get localdatetime</code> to see what this command outputs to understand better how the current date is determined in format <code>YYYY-MM-DD</code>. It would be faster to use <code>%DATE%</code>, but the format of date string of <code>%DATE%</code> depends on the country set in Windows region and language settings and therefore requires knowledge of date string format on computer running this batch file.</p> <p>The command <strong>XCOPY</strong> with the used options does not create the subfolder in backup directory if there is a <code>defects</code> subfolder in a <code>models</code> directory, but in entire <code>defects</code> subfolder tree there is not at least 1 file to copy.</p> <p>Alternate code using environment variable <strong>DATE</strong> with expecting that the expanded date string ends with: <code>MM/DD/YYYY</code>, e.g. <code>Tue 05/17/2016</code>, explained in detail in answer on:<br> <a href="http://stackoverflow.com/a/37236739/3074564">What does %date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2% mean?</a></p> <pre><code>@echo off setlocal rem Define source and backup path. set "SourcePath=C:\machines\models" set "BackupPath=E:\backup" rem Get current date in format YYYY-MM-DD depending on local date format. set "YearMonthDay=%DATE:~-4,4%-%DATE:~-10,2%-%DATE:~-7,2%" rem For each subfolder in source path check if there is a subfolder "defects". rem If subfolder "defects" exists, copy all files and subfolders of "defects" rem to the appropriate backup directory with current date and subfolder name rem in source folder path. Then remove the subfolder "defects" in source rem folder even if being completely empty to avoid processing this folder rem again when not being recreated again in the meantime. for /D %%# in ("%SourcePath%\*") do ( if exist "%%#\defects\*" ( %SystemRoot%\System32\xcopy.exe "%%#\defects\*" "%BackupPath%\%YearMonthDay%\%%~nx#_defects\" /H /I /K /Q /R /S /Y &gt;nul rd /Q /S "%%#\defects" ) ) endlocal </code></pre> <p>For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.</p> <ul> <li><code>echo /?</code></li> <li><code>endlocal /?</code></li> <li><code>for /?</code> ... explains also <code>%%~nx#</code> (name (and extension) of models subfolder).</li> <li><code>if /?</code></li> <li><code>rd /?</code></li> <li><code>set /?</code></li> <li><code>setlocal /?</code></li> <li><code>wmic.exe OS get /?</code></li> <li><code>xcopy /?</code></li> </ul> <p>See also the Microsoft article about <a href="https://technet.microsoft.com/en-us/library/bb490982.aspx" rel="nofollow">Using command redirection operators</a> to understand the meaning of <code>&gt;nul</code>.</p> <p>Why <code>%%~nx#</code> and not just <code>%%~n#</code> as a folder does not have a <em>file extension</em>?</p> <p>Windows command processor does not determine if a string is a folder or a file name. Everything after last backslash is interpreted as <em>file name</em> independent on being in real the name of a file or a folder. And everything after last dot after last backslash in string is interpreted as <em>file extension</em> even if this means that the folder or file name referenced with <code>%~n</code> is an empty string because the folder/file name starts with a dot and does not contain one more dot like many "hidden" files on *nix systems have, e.g. <code>.htaccess</code>. Therefore <code>%~nx</code> should be always used if entire name of a folder or file is needed on a command line.</p>