@echo off
REM Configuration - Customize these variables
set "source_folder=C:\path\to\your\source\folder" REM Replace with the actual source folder path set "destination_share=\server_name\share_name\destination\folder" REM Replace with the shared drive path set "log_file=transfer_log.txt" REM Path to the log file set "file_types=*.txt *.docx *.pdf" REM File types to transfer (e.g., *.txt, *.docx, *.pdf, . for all)
REM Create the log file (overwrite if it exists) echo Transfer started on %DATE% at %TIME% > "%log_file%"
REM Check if the source folder exists if not exist "%source_folder%" ( echo Error: Source folder "%source_folder%" not found. >> "%log_file%" echo Error: Source folder "%source_folder%" not found. pause exit /b 1 )
REM Check if the destination share is accessible (optional but recommended) pushd "%destination_share%" if errorlevel 1 ( echo Error: Destination share "%destination_share%" not accessible. >> "%log_file%" echo Error: Destination share "%destination_share%" not accessible. popd pause exit /b 1 ) popd
REM Transfer files
echo Transferring files from "%source_folder%" to "%destination_share%"... >> "%log_file%" echo Transferring files from "%source_folder%" to "%destination_share%"...
for %%a in (%file_types%) do ( for /r "%source_folder%" %%b in (%%a) do ( echo Copying "%%b" to "%destination_share%"... >> "%log_file%" echo Copying "%%b" to "%destination_share%"... copy "%%b" "%destination_share%" /y REM /y overwrites existing files without prompting if errorlevel 1 ( echo Error copying "%%b". >> "%log_file%" echo Error copying "%%b". ) ) )
echo Transfer complete. >> "%log_file%" echo Transfer complete.
REM Display the log file (optional) notepad "%log_file%"
pause
exit /b 0
why this batch file not working