I have a production mapping where the folder does have more files to copy from one shared location to the other location.
Location A: D:\UK\UK0623\Path\Temp_Variable\ORIGINAL\test1.pdf,test 2.pdf,.....
Location B: D:\UK\UK0723\Path\Temp_Variable\Reissue\
As you see the above challenge, need to work on 3 steps
- Get parent folder path and child folder path from the User and save it in separate Variable till
parent path: D:\UK\UK0623\Path
child path: D:\UK\UK0723\Path
from the Parent path, select and save the first name/folder name as a TEMP variable for example: D:\UK\UK0623\Path\Temp_Variable
Loop thru the TEMP_variable, because we have 100's of folder name available as SNO_01,SNO_02,etc..
get into the Original folder (ParentPath + temp variable + \Original Folder) and copy the files inside Original folder
for example: D:\UK\UK0623\Path\Temp_Variable\Original...
- to the child folder path, use TEMP variable into the path then, Create a Reissue folder, then paste the files in it (ChildPath + temp variable + \Reissue Folder)
for example: D:\UK\UK0723\Path\Temp_Variable\Reissue...
Please note: there are 100's of Serial numbers or folders are there in prod.
Reissue folder needs to create runtime for every serial number SNO_01, SNO_02....
I tried the below script,
@echo off
setlocal enabledelayedexpansion
pushd D:\Uk
SET CURRENT_DIR=%cd%
SET PARENT_DIR=%CURRENT_DIR%\UKRR_0623
SET CHILD_DIR=%CURRENT_DIR%\UKRR_0723
SET TEMP_VAR=SNO_01
echo %CURRENT_DIR%
echo %PARENT_DIR%
echo %CHILD_DIR%
for %%i in ("%CURRENT_DIR%\UKRR_0623\%TEMP_VAR%\Original*.*") do (
copy "%%i" "%CURRENT_DIR%\UKRR_0723\%TEMP_VAR%\Reissue")
echo backup completed
pause
it shows the directory path syntax error
EDIT:
@echo off
setlocal enabledelayedexpansion
pushd D:\Uk
SET CURRENT_DIR=%cd%
SET PARENT_DIR=%CURRENT_DIR%\UKRR_0623
SET CHILD_DIR=%CURRENT_DIR%\UKRR_0723
SET TEMP_VARS=SNO_01 SNO_02
for %%i in (%TEMP_VARS%) do (
xcopy /s "%PARENT_DIR%\%TEMP_VARS%\Original\*.*"
"%CHILD_DIR%\%TEMP_VARS%\Reissue"
)
pause
D:\Uk>(xcopy /s "D:\Uk\UKRR_0623\SNO_01 SNO_02\Original*.*" "D:\Uk\UKRR_0723\SNO_01 SNO_02\Reissue" )File not found - . 0 File(s) copied
set /?(and as it isn't obvious at a first glance: NO SPAC§ES around=(you are defining%CURRENT_DIR %etc))