color coded cli output!
This commit is contained in:
+72
-58
@@ -1,31 +1,44 @@
|
||||
@echo off
|
||||
setlocal
|
||||
setlocal EnableExtensions
|
||||
REM ANSI colors (needs Windows 10+ console VT or Windows Terminal)
|
||||
for /f %%a in ('powershell -nop -c "[char]0x1b"') do set "ESC=%%a"
|
||||
set "RST=%ESC%[0m"
|
||||
set "BLD=%ESC%[1m"
|
||||
set "DIM=%ESC%[2m"
|
||||
set "RED=%ESC%[91m"
|
||||
set "GRN=%ESC%[92m"
|
||||
set "YLW=%ESC%[93m"
|
||||
set "BLU=%ESC%[94m"
|
||||
set "MAG=%ESC%[95m"
|
||||
set "CYN=%ESC%[96m"
|
||||
set "GRY=%ESC%[90m"
|
||||
set "WHT=%ESC%[97m"
|
||||
|
||||
REM Always use 'nathan' as NAS username
|
||||
set NASUSER=nathan
|
||||
|
||||
REM Menu for operation selection
|
||||
echo.
|
||||
echo Select operation:
|
||||
echo 1. Generate thumbnails only
|
||||
echo 2. SSH cleanup only
|
||||
echo 3. Both (generate thumbnails + SSH cleanup)
|
||||
echo 4. Fix OneDrive thumbnail override (NEW!)
|
||||
echo %BLD%%YLW%Select operation:%RST%
|
||||
echo %CYN%1.%RST% Generate thumbnails only
|
||||
echo %CYN%2.%RST% SSH cleanup only
|
||||
echo %CYN%3.%RST% Both (generate thumbnails + SSH cleanup)
|
||||
echo %CYN%4.%RST% Fix OneDrive thumbnail override %DIM%(NEW^)%RST%
|
||||
echo.
|
||||
set /p CHOICE=Enter your choice (1-4):
|
||||
set /p CHOICE=%CYN%Enter your choice ^(1-4^): %RST%
|
||||
|
||||
if "%CHOICE%"=="1" goto THUMBS_ONLY
|
||||
if "%CHOICE%"=="2" goto SSH_ONLY
|
||||
if "%CHOICE%"=="3" goto BOTH
|
||||
if "%CHOICE%"=="4" goto FIX_ONEDRIVE
|
||||
echo Invalid choice. Exiting.
|
||||
echo %RED%Invalid choice. Exiting.%RST%
|
||||
exit /b
|
||||
|
||||
:THUMBS_ONLY
|
||||
REM Prompt for Windows path
|
||||
set /p WINPATH=Enter the full Windows path to your NAS directory (e.g., R:\YouTube\Streams\MixerTwitch):
|
||||
set /p WINPATH=%CYN%Enter the full Windows path to your NAS directory ^(e.g., R:\YouTube\Streams\MixerTwitch^): %RST%
|
||||
if "%WINPATH%"=="" (
|
||||
echo No path provided. Exiting.
|
||||
echo %RED%No path provided. Exiting.%RST%
|
||||
exit /b
|
||||
)
|
||||
|
||||
@@ -34,9 +47,9 @@ set "RELPATH=%WINPATH:~3%"
|
||||
set "RELPATH=%RELPATH:\=/%"
|
||||
set "NASPATH=/volume1/Hydra/%RELPATH%"
|
||||
|
||||
echo Uploading extract_eadir_to_tmp.sh to NAS and seeding...
|
||||
echo %GRN%Uploading extract_eadir_to_tmp.sh to NAS and seeding...%RST%
|
||||
if not exist "%~dp0extract_eadir_to_tmp.sh" (
|
||||
echo ERROR: extract_eadir_to_tmp.sh not found next to this batch file.
|
||||
echo %RED%ERROR: extract_eadir_to_tmp.sh not found next to this batch file.%RST%
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/extract_eadir_to_tmp.sh" < "%~dp0extract_eadir_to_tmp.sh"
|
||||
@@ -48,9 +61,9 @@ goto END
|
||||
|
||||
:SSH_ONLY
|
||||
REM Prompt for Windows path
|
||||
set /p WINPATH=Enter the full Windows path to your NAS directory (e.g., R:\YouTube\Streams\MixerTwitch):
|
||||
set /p WINPATH=%CYN%Enter the full Windows path to your NAS directory ^(e.g., R:\YouTube\Streams\MixerTwitch^): %RST%
|
||||
if "%WINPATH%"=="" (
|
||||
echo No path provided. Exiting.
|
||||
echo %RED%No path provided. Exiting.%RST%
|
||||
exit /b
|
||||
)
|
||||
|
||||
@@ -59,22 +72,22 @@ set "RELPATH=%WINPATH:~3%"
|
||||
set "RELPATH=%RELPATH:\=/%"
|
||||
set "NASPATH=/volume1/Hydra/%RELPATH%"
|
||||
|
||||
echo DEBUG: WINPATH = %WINPATH%
|
||||
echo DEBUG: RELPATH = %RELPATH%
|
||||
echo DEBUG: NASPATH = %NASPATH%
|
||||
echo %GRY%DEBUG: WINPATH = %WINPATH%%RST%
|
||||
echo %GRY%DEBUG: RELPATH = %RELPATH%%RST%
|
||||
echo %GRY%DEBUG: NASPATH = %NASPATH%%RST%
|
||||
echo.
|
||||
call :WIN_REMOVE_LOCAL_EADIR
|
||||
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||
echo %GRN%Uploading nascleanup.sh to NAS and running cleanup...%RST%
|
||||
if not exist "%~dp0nascleanup.sh" (
|
||||
echo ERROR: nascleanup.sh not found next to this batch file.
|
||||
echo %RED%ERROR: nascleanup.sh not found next to this batch file.%RST%
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/nascleanup.sh; else tr -d \"\r\" < ~/nascleanup.sh > ~/nascleanup.sh.tmp && mv ~/nascleanup.sh.tmp ~/nascleanup.sh; fi; chmod +x ~/nascleanup.sh; ~/nascleanup.sh \"%NASPATH%\"'"
|
||||
if errorlevel 1 (
|
||||
echo ERROR: nascleanup failed on NAS - check promote ^(eaDir_tmp -^> @eaDir^) messages above.
|
||||
echo Keeping eaDir_tmp on the share so you can retry without re-running FFmpeg.
|
||||
echo %RED%ERROR: nascleanup failed on NAS - check promote ^(eaDir_tmp -^> @eaDir^) messages above.%RST%
|
||||
echo %YLW%Keeping eaDir_tmp on the share so you can retry without re-running FFmpeg.%RST%
|
||||
call :PRINT_HYDRA_CLEAR_EADIR
|
||||
) else (
|
||||
call :WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
@@ -83,9 +96,9 @@ goto END
|
||||
|
||||
:BOTH
|
||||
REM Prompt for Windows path
|
||||
set /p WINPATH=Enter the full Windows path to your NAS directory (e.g., R:\YouTube\Streams\MixerTwitch):
|
||||
set /p WINPATH=%CYN%Enter the full Windows path to your NAS directory ^(e.g., R:\YouTube\Streams\MixerTwitch^): %RST%
|
||||
if "%WINPATH%"=="" (
|
||||
echo No path provided. Exiting.
|
||||
echo %RED%No path provided. Exiting.%RST%
|
||||
exit /b
|
||||
)
|
||||
|
||||
@@ -94,15 +107,15 @@ set "RELPATH=%WINPATH:~3%"
|
||||
set "RELPATH=%RELPATH:\=/%"
|
||||
set "NASPATH=/volume1/Hydra/%RELPATH%"
|
||||
|
||||
echo DEBUG: WINPATH = %WINPATH%
|
||||
echo DEBUG: RELPATH = %RELPATH%
|
||||
echo DEBUG: NASPATH = %NASPATH%
|
||||
echo %GRY%DEBUG: WINPATH = %WINPATH%%RST%
|
||||
echo %GRY%DEBUG: RELPATH = %RELPATH%%RST%
|
||||
echo %GRY%DEBUG: NASPATH = %NASPATH%%RST%
|
||||
echo.
|
||||
|
||||
REM Pre-seed eaDir_tmp from @eaDir on NAS before generation
|
||||
echo Uploading extract_eadir_to_tmp.sh to NAS and seeding...
|
||||
echo %GRN%Uploading extract_eadir_to_tmp.sh to NAS and seeding...%RST%
|
||||
if not exist "%~dp0extract_eadir_to_tmp.sh" (
|
||||
echo ERROR: extract_eadir_to_tmp.sh not found next to this batch file.
|
||||
echo %RED%ERROR: extract_eadir_to_tmp.sh not found next to this batch file.%RST%
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/extract_eadir_to_tmp.sh" < "%~dp0extract_eadir_to_tmp.sh"
|
||||
@@ -116,16 +129,16 @@ call :WIN_REMOVE_LOCAL_EADIR
|
||||
|
||||
REM SSH cleanup commands (run separately)
|
||||
REM Ensure nascleanup.sh exists on NAS (upload + fix line endings), then run it
|
||||
echo Uploading nascleanup.sh to NAS and running cleanup...
|
||||
echo %GRN%Uploading nascleanup.sh to NAS and running cleanup...%RST%
|
||||
if not exist "%~dp0nascleanup.sh" (
|
||||
echo ERROR: nascleanup.sh not found next to this batch file.
|
||||
echo %RED%ERROR: nascleanup.sh not found next to this batch file.%RST%
|
||||
goto END
|
||||
)
|
||||
ssh Hydra "cat > ~/nascleanup.sh" < "%~dp0nascleanup.sh"
|
||||
ssh Hydra "bash -lc 'if command -v dos2unix >/dev/null 2>&1; then dos2unix -f ~/nascleanup.sh; else tr -d \"\r\" < ~/nascleanup.sh > ~/nascleanup.sh.tmp && mv ~/nascleanup.sh.tmp ~/nascleanup.sh; fi; chmod +x ~/nascleanup.sh; ~/nascleanup.sh \"%NASPATH%\"'"
|
||||
if errorlevel 1 (
|
||||
echo ERROR: nascleanup failed on NAS - check promote ^(eaDir_tmp -^> @eaDir^) messages above.
|
||||
echo Keeping eaDir_tmp on the share so you can retry without re-running FFmpeg.
|
||||
echo %RED%ERROR: nascleanup failed on NAS - check promote ^(eaDir_tmp -^> @eaDir^) messages above.%RST%
|
||||
echo %YLW%Keeping eaDir_tmp on the share so you can retry without re-running FFmpeg.%RST%
|
||||
call :PRINT_HYDRA_CLEAR_EADIR
|
||||
) else (
|
||||
call :WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
@@ -134,29 +147,29 @@ goto END
|
||||
|
||||
:FIX_ONEDRIVE
|
||||
echo.
|
||||
echo =================================================================
|
||||
echo FIX ONEDRIVE THUMBNAIL OVERRIDE
|
||||
echo =================================================================
|
||||
echo %BLD%%MAG%=================================================================%RST%
|
||||
echo %BLD%%MAG% FIX ONEDRIVE THUMBNAIL OVERRIDE %RST%
|
||||
echo %BLD%%MAG%=================================================================%RST%
|
||||
echo.
|
||||
echo This will fix OneDrive overriding your custom thumbnails with
|
||||
echo generic file icons for unsupported formats like .blend files.
|
||||
echo %WHT%This will fix OneDrive overriding your custom thumbnails with%RST%
|
||||
echo %WHT%generic file icons for unsupported formats like .blend files.%RST%
|
||||
echo.
|
||||
echo What this does:
|
||||
echo - Disables OneDrive cloud thumbnail providers
|
||||
echo - Restores local thumbnail priority
|
||||
echo - Prevents future thumbnail cache deletion
|
||||
echo %CYN%What this does:%RST%
|
||||
echo %GRY% - Disables OneDrive cloud thumbnail providers%RST%
|
||||
echo %GRY% - Restores local thumbnail priority%RST%
|
||||
echo %GRY% - Prevents future thumbnail cache deletion%RST%
|
||||
echo.
|
||||
set /p CONFIRM=Continue? (y/n):
|
||||
set /p CONFIRM=%YLW%Continue? ^(y/n^): %RST%
|
||||
if /i not "%CONFIRM%"=="y" goto END
|
||||
|
||||
echo.
|
||||
echo Running PowerShell script to fix OneDrive thumbnail override...
|
||||
echo %GRN%Running PowerShell script to fix OneDrive thumbnail override...%RST%
|
||||
echo.
|
||||
|
||||
REM Check if PowerShell script exists
|
||||
if not exist "fix_thumbnail_override.ps1" (
|
||||
echo ERROR: fix_thumbnail_override.ps1 not found in current directory.
|
||||
echo Please ensure the PowerShell script is in the same folder as this batch file.
|
||||
echo %RED%ERROR: fix_thumbnail_override.ps1 not found in current directory.%RST%
|
||||
echo %YLW%Please ensure the PowerShell script is in the same folder as this batch file.%RST%
|
||||
pause
|
||||
goto END
|
||||
)
|
||||
@@ -165,31 +178,31 @@ REM Run PowerShell script as administrator
|
||||
powershell -ExecutionPolicy Bypass -Command "Start-Process PowerShell -ArgumentList '-ExecutionPolicy Bypass -File \"%~dp0fix_thumbnail_override.ps1\"' -Verb RunAs"
|
||||
|
||||
echo.
|
||||
echo OneDrive thumbnail override fix initiated.
|
||||
echo Please check the PowerShell window for progress and results.
|
||||
echo %GRN%OneDrive thumbnail override fix initiated.%RST%
|
||||
echo %GRY%Please check the PowerShell window for progress and results.%RST%
|
||||
echo.
|
||||
echo After the fix completes:
|
||||
echo 1. Restart your computer
|
||||
echo 2. Re-run your thumbnail generation process
|
||||
echo 3. Your custom thumbnails should now have priority!
|
||||
echo %CYN%After the fix completes:%RST%
|
||||
echo %GRY% 1. Restart your computer%RST%
|
||||
echo %GRY% 2. Re-run your thumbnail generation process%RST%
|
||||
echo %GRY% 3. Your custom thumbnails should now have priority!%RST%
|
||||
echo.
|
||||
goto END
|
||||
|
||||
REM Print ssh Hydra command to wipe @eaDir when NAS cleanup failed (matches NASPATH from pasted R:\ path).
|
||||
:PRINT_HYDRA_CLEAR_EADIR
|
||||
if "%NASPATH%"=="" goto :eof
|
||||
echo To clear locked @eaDir on Hydra: ssh in first, then run:
|
||||
echo sudo rm -rf "%NASPATH%/@eaDir"
|
||||
echo %MAG%To clear locked @eaDir on Hydra: ssh in first, then run:%RST%
|
||||
echo %BLD%%YLW% sudo rm -rf "%NASPATH%/@eaDir"%RST%
|
||||
goto :eof
|
||||
|
||||
REM Remove folder-level @eaDir on the pasted Windows path (same files as NAS over SMB).
|
||||
:WIN_REMOVE_LOCAL_EADIR
|
||||
if "%WINPATH%"=="" goto :eof
|
||||
if exist "%WINPATH%\@eaDir" (
|
||||
echo Removing "%WINPATH%\@eaDir" via Windows ^(SMB share^)...
|
||||
echo %CYN%Removing "%WINPATH%\@eaDir" via Windows ^(SMB share^)...%RST%
|
||||
rd /s /q "%WINPATH%\@eaDir" 2>nul
|
||||
if exist "%WINPATH%\@eaDir" (
|
||||
echo WARNING: Could not remove @eaDir; try PowerShell as admin or delete in Explorer.
|
||||
echo %YLW%WARNING: Could not remove @eaDir; try PowerShell as admin or delete in Explorer.%RST%
|
||||
)
|
||||
)
|
||||
goto :eof
|
||||
@@ -197,13 +210,14 @@ goto :eof
|
||||
REM Remove every eaDir_tmp under pasted path (including subfolders e.g. gameplay\eaDir_tmp).
|
||||
:WIN_REMOVE_LOCAL_EADIR_TMP
|
||||
if "%WINPATH%"=="" goto :eof
|
||||
echo Removing all eaDir_tmp folders under "%WINPATH%" ^(recursive, SMB^)...
|
||||
echo %CYN%Removing all eaDir_tmp folders under "%WINPATH%" ^(recursive, SMB^)...%RST%
|
||||
if not exist "%~dp0remove_eadir_tmp_recursive.ps1" (
|
||||
echo ERROR: remove_eadir_tmp_recursive.ps1 not found next to this batch file.
|
||||
echo %RED%ERROR: remove_eadir_tmp_recursive.ps1 not found next to this batch file.%RST%
|
||||
goto :eof
|
||||
)
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0remove_eadir_tmp_recursive.ps1" "%WINPATH%"
|
||||
goto :eof
|
||||
|
||||
:END
|
||||
pause
|
||||
echo %DIM%Press any key to continue . . .%RST%
|
||||
pause >nul
|
||||
|
||||
Reference in New Issue
Block a user