-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1 drag & drop pak files onto this bat file.bat
More file actions
111 lines (96 loc) · 2.29 KB
/
Copy path1 drag & drop pak files onto this bat file.bat
File metadata and controls
111 lines (96 loc) · 2.29 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@echo off
setlocal EnableDelayedExpansion
title Mod Merger Launcher
:: Set colors for output
color 0b
:: Store the script's directory
set "SCRIPT_DIR=%~dp0"
set "PYTHON_SCRIPT=%SCRIPT_DIR%1_Python_Merging_s2hoc.py"
:: Clear screen
cls
echo Mod Merger Launcher
echo =================
echo.
:: Validate if Python script exists
if not exist "%PYTHON_SCRIPT%" (
color 0c
echo ERROR: Cannot find the Python script at:
echo %PYTHON_SCRIPT%
echo.
echo Please ensure the batch file is in the same directory as the Python script.
echo.
pause
exit /b 1
)
:: Check if any files were dropped
if "%~1"=="" (
echo Usage: Drag and drop .pak files onto this batch file
echo.
pause
exit /b 1
)
:: Initialize variables
set "VALID_FILES="
set "INVALID_FILES="
set "FILE_COUNT=0"
:: Validate all dropped files
for %%F in (%*) do (
set /a FILE_COUNT+=1
if /i "%%~xF"==".pak" (
set "VALID_FILES=!VALID_FILES! "%%~fF""
) else (
set "INVALID_FILES=!INVALID_FILES! %%~nxF"
)
)
:: Check for invalid files
if not "!INVALID_FILES!"=="" (
color 0e
echo Warning: The following files are not .pak files and will be ignored:
echo !INVALID_FILES!
echo.
timeout /t 3 >nul
)
:: Check if we have any valid files to process
if "!VALID_FILES!"=="" (
color 0c
echo ERROR: No valid .pak files were provided.
echo Please drag and drop .pak files only.
echo.
pause
exit /b 1
)
:: Try to locate Python
where python >nul 2>nul
if %ERRORLEVEL% neq 0 (
where py >nul 2>nul
if %ERRORLEVEL% neq 0 (
color 0c
echo ERROR: Python is not found in the system PATH
echo Please install Python and ensure it's added to the system PATH
echo.
pause
exit /b 1
)
set "PYTHON_CMD=py"
) else (
set "PYTHON_CMD=python"
)
:: Display summary
color 0a
echo Found !FILE_COUNT! files to process
echo.
echo Starting merge process...
echo.
:: Execute the Python script with the valid files
%PYTHON_CMD% "%PYTHON_SCRIPT%" %VALID_FILES%
:: Check if Python script execution had an error
if %ERRORLEVEL% neq 0 (
color 0c
echo.
echo ERROR: The Python script encountered an error.
echo.
pause
exit /b 1
)
:: Normal exit - no need to pause since Python script has its own exit prompt
exit /b 0