-
Notifications
You must be signed in to change notification settings - Fork 0
/
findvalidfiles.bat
65 lines (45 loc) · 2.25 KB
/
findvalidfiles.bat
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
@echo off
setlocal enabledelayedexpansion
rem set important variables:
rem check for valid %1 input
if "%~1" == "" ( goto ProcessErrorEmptyArg )
rem if [%1] == [] ( goto ProcessErrorEmptyArg ), stripped out quotes via ~, change [] to "" for check of unknown variables
rem arg is input parameter
set arg=%1
rem modsfolder is path to pdx mod folder
set modsfolder=%HOMEDRIVE%%HOMEPATH%\Documents\Paradox Interactive\Crusader Kings III
rem iterate through the current folder and its sub folders, without default delimiters
rem if nothing found, search other folder for specifed file. same parameters.
for /f "delims=" %%i in ('dir /b/s "..\%arg%" 2^>nul') do (
rem add every found matching the given parameter %1 to variable var
set var=%%i !var!
)
:::::::::::::::::::::::::::::::::::::::::::::::::::::
rem search secondary directory, your pdx mods folder: CURRENTLY OUT OF ORDER, ICE CREAM MACHINE BROKE!!!!
rem for real tho, it doesnt do what i want it to do. it keeps spitting out nonsensical crap i cant use.
:::::::::::::::::::::::::::::::::::::::::::::::::::::
@REM rem change dir to your local mods folder in Documents --------------------(TODO implement customizable mod location to make compatible with other pdx titles.)
@REM chdir /d "%modsfolder%"
@REM rem quotes protect path, errors could occur if path contains spaces
@REM rem checks for invalid mods folder path, sends you to endoffile and throws errorlevel 2
@REM if %errorlevel% == 1 ( goto ProcessErrorInvalidPath )
@REM rem iterate through the current folder and its sub folders, without default delims(delimiters)
@REM for /f "delims=" %%b in ('dir /b/s "..\%arg%" 2^>nul') do (
@REM set var=%%b !var!
@REM )
rem checks if script found anything, if not, itll abort
if "!var!" == "" ( goto ProcessErrorNothingFound )
rem echo the findings for other programs to catch
echo !var!
:EndOfFile
endlocal
exit /b 0 rem exit with errorlevel 0; everything went well
:ProcessErrorEmptyArg
endlocal
exit /b 1 rem exit with errorlevel 1; no arguments passed to this file
:ProcessErrorInvalidPath
endlocal
exit /b 2 rem exit with errorlevel 2; invalid path
:ProcessErrorNothingFound
endlocal
exit /b 3 rem exit with errorlevel 3; no Results found