Skip to content

Commit 79ce08d

Browse files
committed
Added readable variables for common color formatting
1 parent 8a02662 commit 79ce08d

1 file changed

Lines changed: 28 additions & 26 deletions

File tree

batch encoder.bat

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ if /i "%1"=="--updated-from" (
1313
set "icongray="
1414
set "iconyellow="
1515
set "icongreen="
16-
set "iconend="
17-
16+
set "textgray="
17+
set "textgreen="
18+
set "textred="
19+
set "formatend="
1820

1921
:AskProceed
2022
call:ClearAndTitle
21-
echo %icongray% i %iconend% This program will aim to encode all .mp4 files in the folder it's placed in and delete the originals.
22-
set /p "startconfirmation=Do you want to proceed? [90m[Y/N][0m: "
23+
echo %icongray% i %formatend% This program will aim to encode all .mp4 files in the folder it's placed in and delete the originals.
24+
set /p "startconfirmation=Do you want to proceed? %textgray%[Y/N]%formatend%: "
2325
if /i "%startconfirmation%"=="n" exit
2426
if /i "%startconfirmation%"=="y" (goto AskUpdate)
2527
goto AskProceed
2628

2729
:AskUpdate
2830
call:ClearAndTitle
29-
set /p "updateconfirmation=%icongray% ^ %iconend% Would you like to check for an update? [90m[Y/N][0m: "
31+
set /p "updateconfirmation=%icongray% ^ %formatend% Would you like to check for an update? %textgray%[Y/N]%formatend%: "
3032
if /i "%updateconfirmation%"=="n" (goto FFMPEGLocation)
3133
if /i "%updateconfirmation%"=="y" (goto AutoUpdate)
3234
goto AskUpdate
3335

3436
:AutoUpdate
3537
call:ClearAndTitle
36-
echo %icongray% i %iconend% Downloading information...
38+
echo %icongray% i %formatend% Downloading information...
3739
set "updateFileName=batch_update.json"
3840
curl --silent -L -H "Accept: application/vnd.github+json" -o %updateFileName% https://api.github.com/repos/Adam-Kay/Batch-Encoder/releases/latest
3941
rem curl --silent -o batch_update.txt https://gist.githubusercontent.com/Adam-Kay/ec5da0ff40e8eb14beee2242161f5191/raw
@@ -54,21 +56,21 @@ set "iconend="
5456

5557
echo.
5658
if /i "%UpdateVersion%"=="%CurrentVersion%" (
57-
echo %icongray% - %iconend% Current version is up-to-date.
59+
echo %icongray% - %formatend% Current version is up-to-date.
5860
echo.
5961
echo The program will now restart.
6062
call:GrayPause
6163
del "%updateFileName%"
6264
goto AskProceed
6365
) else (
64-
echo %iconyellow% ^^! %iconend% Differing version found^^! ^([31m%CurrentVersion%[0m -^> [32m%UpdateVersion%[0m^)
66+
echo %iconyellow% ^^! %formatend% Differing version found^^! ^(%textred%%CurrentVersion%%formatend% -^> %textgreen%%UpdateVersion%%formatend%^)
6567
echo Proceeding with update in 5 seconds, press CTRL+C or close window to cancel.
6668
echo.
6769
timeout /nobreak /t 5 > nul
6870
echo Downloading files...
6971
curl --silent -L -H "Accept: application/octet-stream" -o "batch encoder %UpdateVersion%%append%.bat" %UpdateAPIURL%
7072
echo.
71-
echo %icongreen% i %iconend% Download complete. The program will now clean up and restart.
73+
echo %icongreen% i %formatend% Download complete. The program will now clean up and restart.
7274
call:GrayPause
7375
del "%updateFileName%"
7476
(goto) 2>nul & "batch encoder %UpdateVersion%%append%.bat" --updated-from "%~f0"
@@ -77,7 +79,7 @@ set "iconend="
7779
:FFMPEGLocation
7880
call:ClearAndTitle
7981
rem TODO: detect FFMPEG if in same folder
80-
set /p "LOCATION=%icongray% ? %iconend% Where is FFMPEG.exe located? (paste full path): "
82+
set /p "LOCATION=%icongray% ? %formatend% Where is FFMPEG.exe located? (paste full path): "
8183

8284
set /a "COUNTER=-1"
8385

@@ -102,7 +104,7 @@ set "INPUTFILE="
102104
call:GrayTimeout 2
103105
) else (
104106
set /a "COUNTER+=1"
105-
echo [100m Encoding !COUNTER! of %TOTAL% [0m
107+
echo [100m Encoding !COUNTER! of %TOTAL% %formatend%
106108
rem echo **********************************
107109

108110
set "TESTSTRING=!INPUTFILE:~-4!"
@@ -129,23 +131,23 @@ set "INPUTFILE="
129131
echo ***********************
130132
echo.
131133

132-
echo %icongray% ^| %iconend% Checking for output file...
134+
echo %icongray% ^| %formatend% Checking for output file...
133135
if /i not exist "%CD%\!OUTPUTFILE!" goto CritError
134136
echo - Output file exists^^!
135137
echo.
136138

137-
echo %icongray% ^| %iconend% Checking output file length...
139+
echo %icongray% ^| %formatend% Checking output file length...
138140
for /F "tokens=*" %%g in (
139141
'powershell -Command "$Shell = New-Object -ComObject Shell.Application; $Folder = $Shell.Namespace('%cd%'); $Folder.GetDetailsOf($Folder.ParseName('!INPUTFILE!'), 27)"'
140-
) do (set LEN_inP=%%g)
142+
) do (set LEN_INP=%%g)
141143
for /F "tokens=*" %%g in (
142144
'powershell -Command "$Shell = New-Object -ComObject Shell.Application; $Folder = $Shell.Namespace('%cd%'); $Folder.GetDetailsOf($Folder.ParseName('!OUTPUTFILE!'), 27)"'
143145
) do (set LEN_OUT=%%g)
144-
echo Input file: !LEN_inP! - Output file: !LEN_OUT!
145-
if /i not "!LEN_inP!"=="!LEN_OUT!" goto CritError
146+
echo Input file: !LEN_INP! - Output file: !LEN_OUT!
147+
if /i not "!LEN_INP!"=="!LEN_OUT!" goto CritError
146148
echo - File lengths match^^!
147149
echo.
148-
echo %icongreen% ^| %iconend% Safely proceeding with input file recycling...
150+
echo %icongreen% ^| %formatend% Safely proceeding with input file recycling...
149151
timeout /nobreak /t 1 > nul
150152

151153
powershell -Command "(Get-Item '%CD%\!OUTPUTFILE!').CreationTime=((Get-Item '%CD%\!INPUTFILE!').CreationTime)"
@@ -159,7 +161,7 @@ set "INPUTFILE="
159161
)
160162

161163
call:ClearAndTitle
162-
echo [42;97m Completed encoding %TOTAL% files. [0m
164+
echo [42;97m Completed encoding %TOTAL% files. %formatend%
163165

164166
:EndPause
165167
call:GrayPause
@@ -186,30 +188,30 @@ echo  Completed encoding %TOTAL% files. 
186188
goto AskProceed
187189

188190
:GrayPause
189-
echo [90m
191+
echo %textgray%
190192
pause
191-
echo [0m
193+
echo %formatend%
192194
goto:eof
193195

194196
:GrayTimeout
195197
set timer=%~1
196-
<nul set /p=[90m
198+
<nul set /p=%textgray%
197199
for %%a in (timer) do if not defined %%a (
198200
timeout /t 5
199201
) else (
200202
timeout /t %timer%
201203
)
202-
echo [0m
204+
echo %formatend%
203205
goto:eof
204206

205207
:ErrorLine
206-
rem echo [4;31m [0m
207-
echo [31m************************************************************[0m
208-
rem echo [7;31m ********************************************************** [0m
208+
rem echo [4;31m %formatend%
209+
echo %textred%************************************************************%formatend%
210+
rem echo [7;31m ********************************************************** %formatend%
209211
goto:eof
210212

211213
:ClearAndTitle
212214
cls
213-
echo [7m Batch Encoder %CurrentVersion% [0m
215+
echo [7m Batch Encoder %CurrentVersion% %formatend%
214216
echo.
215217
goto:eof

0 commit comments

Comments
 (0)