Hello gurus,
I am facing the below issue.
I have some files in directory Dir_1 , and I need to copy them in another directory Dir_2.
Well, here I go.
I thought this would have done the job, but it isn’t.
What am I missing?
@echo off & setLocal EnableDELAYedeXpansion
pushd D:\Dir_1
for /F %%j in (dir D:\Dir_1 /A-D | find /c "OK_ARCHIVE") do set Count=%%jdo set Count=%%j
if %count% EQU 0 (
echo No files found in the specified folder>>FilesError.log
) else (
for /L %%b in (1 1 %count%) do ( xcopy "D:\Dir_1" "G:\Dir_2" /D /I /Y)
echo A total of !count! files have been copied>>FilesSuccess.log
)
move FilesSuccess.log D:\Dir_3
move FilesError.log D:\Dir_3
after executing, I am getting
| was unexpected at this time.
Please help,
Thnx and regards
@echo off & setlocal set source=D:\Dir_1 set target=G:\Dir_2 cd /D "%source%" if not exist "%target%" md "%target%" if not exist "D:\Dir_3\FilesList.log" type nul > "D:\Dir_3\FilesList.log" set stamp=%date:~-10% on %time:~0,8% set cnt=0 for %%j in (*) do if %%~zj geq 50 if not exist "%target%.\%%j" ( type "D:\Dir_3\FilesList.log" | find /I "%%j" > nul if ErrorLevel 1 ( copy "%%j" "%target%" > nul echo.%stamp% %%j>> "D:\Dir_3\FilesList.log" set /A cnt+=1 ) ) if %cnt% equ 0 ( echo.no files found echo.%stamp% no files found>> "D:\Dir_3\FilesError.log" ) else ( echo.%cnt% files copied echo.%stamp% %cnt% files copied>> "D:\Dir_3\FilesSuccess.log" )