-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-is-equal.bat
More file actions
36 lines (28 loc) · 863 Bytes
/
file-is-equal.bat
File metadata and controls
36 lines (28 loc) · 863 Bytes
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
@echo off
setlocal enabledelayedexpansion
if "%~1"=="" (
echo Usage: %~nx0 file1 [file2 ... fileN]
exit /b 1
)
rem --- Compute hash of the first file
set "first=%~1"
for /f "usebackq tokens=*" %%H in (`
powershell -NoProfile -Command "Get-FileHash -Algorithm SHA256 '%first%' ^| Select-Object -ExpandProperty Hash"
`) do set "baseHash=%%H"
shift
:compare_next
if "%~1"=="" goto all_equal
rem --- Compute hash of the next file
set "current=%~1"
for /f "usebackq tokens=*" %%H in (`
powershell -NoProfile -Command "Get-FileHash -Algorithm SHA256 '%current%' ^| Select-Object -ExpandProperty Hash"
`) do set "nextHash=%%H"
if /I "!baseHash!" neq "!nextHash!" (
echo NOT identical: "%first%" vs "%current%"
exit /b 2
)
shift
goto compare_next
:all_equal
echo All files (%*) are identical.
exit /b 0