-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremove-sesaves-symlinks.bat
More file actions
85 lines (73 loc) · 2.19 KB
/
remove-sesaves-symlinks.bat
File metadata and controls
85 lines (73 loc) · 2.19 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
73
74
75
76
77
78
79
80
81
82
83
84
85
@echo off
setlocal enabledelayedexpansion
REM Ensure the script runs as administrator
>nul 2>&1 "%SystemRoot%\system32\cacls.exe" "%SystemRoot%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo.
echo ====================================================
echo This script must be run as an administrator to delete symlinks!
echo Right-click the script and select "Run as administrator".
echo ====================================================
echo.
pause
exit /b
)
REM Define the root Space Engineers save directory
set saveRootDir="%APPDATA%\SpaceEngineers\Saves"
REM Verify if the root save directory exists
if not exist !saveRootDir! (
echo Save directory does not exist: !saveRootDir!
echo Unable to proceed.
pause
exit /b
)
REM Change to the save directory
cd /d "!saveRootDir!"
REM Locate the latest Steam ID directory
set latestSteamID=
for /d %%i in (*) do (
if exist "%%i\*" (set latestSteamID=%%i)
)
REM Check if a Steam ID directory was found
if "!latestSteamID!"=="" (
echo No valid Steam ID directory found.
pause
exit /b
)
REM Change to the Steam ID directory
set targetDir=!saveRootDir!\!latestSteamID!
cd /d "!targetDir!"
REM List and confirm removal of symbolic links
echo Searching for symbolic links in: !targetDir!
set foundSymlink=false
for /f "tokens=*" %%l in ('dir /AL /B') do (
set foundSymlink=true
echo Found symlink: %%l
)
REM Check if no symbolic links were found
if "!foundSymlink!"=="false" (
echo No symbolic links found in: !targetDir!
pause
exit /b
)
REM Prompt user for confirmation
set /p confirmDelete="Do you want to delete all symlinks in this directory? [Y/N]: "
if /i "!confirmDelete!" NEQ "Y" (
echo Operation canceled. No symlinks were removed.
pause
exit /b
)
REM Delete symbolic links
echo Deleting symbolic links in: !targetDir!
for /f "tokens=*" %%l in ('dir /AL /B') do (
echo Removing symlink: %%l
rmdir "%%l"
if !errorlevel! == 0 (
echo Successfully removed symlink: %%l
) else (
echo Failed to remove symlink: %%l. Check permissions or path issues.
)
)
REM Completion message
echo All symbolic links have been removed from: !targetDir!
pause