-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull_volume.bat
More file actions
72 lines (60 loc) · 2.4 KB
/
full_volume.bat
File metadata and controls
72 lines (60 loc) · 2.4 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
72
@echo off
setlocal EnableExtensions EnableDelayedExpansion
cls && mode con cols=120 lines=7 & cd /d "%~dp0"
set "_target_directory=C:\"
set "_hash_data=%_target_directory%\hash.txt"
set "_csv_file_path=C:\output\app_remover_%date:~-4%%date:~-7,2%%date:~-10,2%_%time:~0,2%%time:~3,2%%time:~6,2%.csv"
if not exist "%_target_directory%" (
echo Target directory "%_target_directory%" does not exist.
goto :_end_of_file_:
)
if not exist "%_hash_data%" (
echo Hash data file "%_hash_data%" not found.
goto :_end_of_file_:
)
echo "Action","File Path","Hash Value" > "%_csv_file_path%"
for /r "%_target_directory%" %%i in (*) do (
if /i not "%%~nxi" == "%~nx0" (
set "_hash="
for /f %%j in ('powershell -Command "Get-FileHash '%%i' -Algorithm SHA256 | Select-Object -ExpandProperty Hash"') do (
set "_hash=%%j"
)
findstr /i /c:"!_hash!" "%_hash_data%" >nul
if !errorlevel! equ 0 (
echo "Deleted","%%i","!_hash!" >> "%_csv_file_path%"
echo Deleting "%%i" with hash value !_hash!
icacls "%%i" /inheritance:r >nul 2>&1
del /q /f "%%i"
) else (
echo "Not Deleted","%%i","!_hash!" >> "%_csv_file_path%"
echo Not deleting "%%i" with hash value !_hash!
)
)
)
echo Total files scanned: !errorlevel!
for /d %%d in (C:\*) do (
if not "%%~nxd" == "Windows" (
set "_target_directory=%%d"
for /r "!_target_directory!" %%i in (*) do (
if /i not "%%~nxi" == "%~nx0" (
set "_hash="
for /f %%j in ('powershell -Command "Get-FileHash '%%i' -Algorithm SHA256 | Select-Object -ExpandProperty Hash"') do (
set "_hash=%%j"
)
findstr /i /c:"!_hash!" "%_hash_data%" >nul
if !errorlevel! equ 0 (
echo "Deleted","%%i","!_hash!" >> "%_csv_file_path%"
echo Deleting "%%i" with hash value !_hash!
icacls "%%i" /inheritance:r >nul 2>&1
del /q /f "%%i"
) else (
echo "Not Deleted","%%i","!_hash!" >> "%_csv_file_path%"
echo Not deleting "%%i" with hash value !_hash!
)
)
)
)
)
echo Total files scanned: !errorlevel!
:_end_of_file_:
pause