-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy-FilesFixed.bat
More file actions
71 lines (59 loc) · 2.12 KB
/
Copy-FilesFixed.bat
File metadata and controls
71 lines (59 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
setlocal EnableDelayedExpansion
:: Simple Robocopy for File Integrity (No Permissions)
:: Fixed version with proper path quoting for spaces
echo ====================================
echo File Copy - Integrity Preservation
echo ====================================
echo.
:: Configuration - Update these paths as needed (DO NOT include quotes here)
set SOURCE=Z:\Shared Documents\CopyTest
set DESTINATION=Y:\Shared Documents\New folder
:: Create log filename with timestamp
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "timestamp=%YYYY%%MM%%DD%_%HH%%Min%%Sec%"
set LOGFILE=%USERPROFILE%\Documents\FileCopy_!timestamp!.log
echo Source: "%SOURCE%"
echo Destination: "%DESTINATION%"
echo Log File: "%LOGFILE%"
echo.
:: Verify source exists
if not exist "%SOURCE%" (
echo ERROR: Source path does not exist: "%SOURCE%"
echo Please check the source path and try again.
pause
exit /b 1
)
echo Starting copy operation...
echo ** This preserves file integrity without permissions **
echo.
:: Execute Robocopy with proper quoting
robocopy "%SOURCE%" "%DESTINATION%" /E /COPY:DAT /DCOPY:DAT /R:3 /W:5 /MT:4 /NP /TEE /UNILOG:"%LOGFILE%" /XJD /XJF
:: Check exit code
set EXITCODE=%ERRORLEVEL%
echo.
echo ================
echo Operation Complete
echo ================
echo Exit Code: %EXITCODE%
if %EXITCODE% EQU 0 (
echo Status: SUCCESS - No files needed copying
) else if %EXITCODE% EQU 1 (
echo Status: SUCCESS - Files copied successfully
) else if %EXITCODE% EQU 2 (
echo Status: SUCCESS - Some additional files found
) else if %EXITCODE% EQU 3 (
echo Status: SUCCESS - Files copied and additional files found
) else if %EXITCODE% LEQ 7 (
echo Status: WARNING - Copy completed with minor issues
echo Check log file for details: "%LOGFILE%"
) else (
echo Status: ERROR - Copy operation had significant issues
echo Check log file for details: "%LOGFILE%"
)
echo.
echo Log file location: "%LOGFILE%"
echo.
pause