i’m struggeling with some batch programming in windows where i didn’t get the result i’m looking for.
I do have a folder containing hundreds of files having always a set of 3 files belonging together:
BWMKE_PROD_DAP_WOTERM01_1000_1_280624_100320_5.pdf
BWMKE_PROD_DAP_WOTERM01_1000_1_280624_100320_5_Archiv.xml
BWMKE_PROD_DAP_WOTERM01_1000_1_280624_100320_5_Daten.xml
I would now to move all PDF reaching certain threshold in terms of filesize and their corresponding XML files to a seperate folder.
The PDF piece is already working but how do i get the corresponding XML files identified/moved as well?
Thanks in advance
BR Oliver
that’s what i have so far, but forfiles give me an error: Files of type “*.xml not found.
I tried findstr as well, without luck
@echo off
setlocal enabledelayedexpansion
set "SOURCE_DIR=D:/AFI/S4I/D4P_Prod/Archive/PDF_Orig_Test"
set "DESTINATION_DIR=D:/AFI/S4I/D4P_Prod/Archive/TMP_Dir"
set "FILE_SIZE=5000000"
set "logfile=%date:~-4%-%date:~-7,2%-%date:~-10,2%.log"
call :main
goto :EOF
:main
echo "%FILE_SIZE%" | findstr ""[0-9][0-9]*"" > NUL
if errorlevel 1 (
echo An error occured
exit /b 1
)
for /R "%SOURCE_DIR%" %%F in ("*.*") do (
if exist "%%F" if %%~zF GEQ %FILE_SIZE% (
echo %%F >> "log_big_files/large_files_%logfile%"
move "%%~dpnF" "%DESTINATION_DIR%"
echo %%~nF
forfiles /M "%%~nF*.xml" /C "cmd /C move <RESULT> "%DESTINATION_DIR%""
)
)
goto :EOF
Oliver Lewald is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.