I modified the script as below in order to meet directory structure mentioned in my last comment.
::Adjust folder names and filelist name for specific tree copy
@echo off & setLocal EnableDELAYedeXpansion
xcopy /t /e /i /h src_tree src_tree_bkp
dir /s /b /a-d src_tree > filelist_src_tree
::chdir gives D:/dir1/dir2/dir3/dir4 Then token is 1 to 6 (i.e. MaxDirLvl+2 = 4+2 = 6)
::adjust token names accordingly in a given directory
for /f "usebackq tokens=1-5* delims=\ " %%A in ("filelist_src_tree") do (
copy "%%~fE\%%F" "%%~fA\src_tree_bkp\%%F"
But I think it is done in amateur fashion because I need to change token names depending on the folder depth (no of levels away from base drive).
Also I want to copy tree structure using directory list generated previous to compilation. Because xcopy in above script is going to copy directories created during compilation too, which is not needed.
Could anybody provide some inputs?