-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy-FilesSimple.bat
More file actions
63 lines (52 loc) · 1.93 KB
/
Copy-FilesSimple.bat
File metadata and controls
63 lines (52 loc) · 1.93 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
@echo off
setlocal
:: Simple Robocopy for File Integrity (No Permissions)
:: Focuses on preserving timestamps, attributes, and versioning without security issues
echo ====================================
echo File Copy - Integrity Preservation
echo ====================================
echo.
:: Configuration - Update these paths as needed
set SOURCE="\\sharesource\Securitydocs\StrategyFiles"
set DESTINATION="\\DestinationSource\SecurityDocs\StrategyFiles"
:: 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="%TEMP%\FileCopy_%timestamp%.log"
echo Source: %SOURCE%
echo Destination: %DESTINATION%
echo Log File: %LOGFILE%
echo.
echo Starting copy operation...
echo ** This preserves file integrity without permissions **
echo.
:: Execute Robocopy - Focus on Data, Attributes, Timestamps only
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: %LOGFILE%
echo.
pause