1

How do I edit this texconv "IMGtoBC3.bat" file so it "READS FROM & PRESERVES the directory structure when writing the "resulting" dds files?

Personally, I have a large folder/sub-folders with many tiff's that "have the same file name" divided up into "sets".

These dds files are for custom textures in a unity game, file naming is a forced event, but "sorted/selected" by folder.

I have about 3000 file sets ready to convert and I'm not doing them 1 by 1 in Nvidia tool (I hope) and AMD tool and the game have a MAJOR conflict (its as a no go)

ECHO OFF
Setlocal EnableDelayedExpansion

::Variables SET @FORMAT=BC3_UNORM SET @InputFolder=%~dp0Input_IMG_TO_BC3
SET @OutputFolder=%~dp0Output_DXT5_BC3
SET @TEXCONVEXE=%~dp0texconv.exe SET @TEXCONVEXE02=%~dp0texconv.exe :: Check for texconv.exe IF EXIST "%@TEXCONVEXE%" SET @TEXCONVEXE=1 IF "%@TEXCONVEXE%"=="1" GOTO EXESTATE_1

:EXESTATE_0 TITLE - ERROR! texconv.exe not found!!! COLOR 04 ECHO: && ECHO: && ECHO: ECHO === ERROR! texconv.exe not found!=== ECHO: ECHO Install Path: "%~dp0texconv.exe" ECHO: ECHO The script needs texconv.exe in order to work properly. ECHO: ECHO Please make sure texconv.exe is in: "%~dp0"

ECHO: && ECHO:

GOTO CONT01

:EXESTATE_1 TITLE - Texconv.exe found!!! COLOR 0A

ECHO: && ECHO: && ECHO: ECHO [ texconv.exe Is Installed! ] ECHO: ECHO "%~dp0texconv.exe" ECHO: GOTO CONT00 :CONT01 ECHO: && ECHO: ECHO Please copy/move the missing texconv.exe executable to where the script needs it to be and refresh this window. ECHO: :CONT00 IF "%@TEXCONVEXE%"=="1" GOTO START ECHO: && ECHO: && ECHO [Press any key to refresh the window] && PAUSE>NUL GOTO SetTexConvPath

:START

:: Customize CMD Window TITLE HumanStuff TexConv Batch Directory Script v1.0.2 PROMPT $G COLOR 04 CLS

:: Make The Folders IF NOT EXIST "%@InputFolder%" MKDIR "%@InputFolder%" IF NOT EXIST "%@OutputFolder%" MKDIR "%@OutputFolder%"

::Run TexConv.exe ::-srgb was added because PNG images were getting high contrast colors ::Sorry about the messy code but this was harder to do than it sounds

FOR /R "%@InputFolder%" %%i IN (.) DO ( set word=%@OutputFolder% set str=%%~dpi CALL :REPLACESTRING SET @IFOL=!@OSTRING! CALL :MKFOL SET @ISTRING=%%i CALL :TexConv01 )

PAUSE GOTO SCRIPTEND

:MKFOL IF NOT EXIST "%@IFOL%" ( MKDIR "%@IFOL%" ) GOTO SCRIPTEND

:TexConv01 IF NOT "%@LOGO%"=="" SET @LOGO=-nologo "%@TEXCONVEXE02%" %@LOGO% -srgb -nogpu -pow2 -vflip -if triangle -bc u -f %@FORMAT% "%@ISTRING%" -o "%@OSTRING%" -y ECHO: SET @LOGO= GOTO SCRIPTEND

:REPLACESTRING call set str=%%str:%@InputFolder%=%word%%% set @OSTRING=!str:~0,-1! GOTO SCRIPTEND

:SCRIPTEND

DavidPostill
  • 162,382

1 Answers1

1

enter image description here

@echo off

cd /d "%~dp0" setlocal enabledelayedexpansion if not exist "%~dp0texconv.exe" goto :error

set "_flag=-nologo -srgb -gpu 1 -pow2 -vflip" set "_flag=!_flag! -if triangle -f BC3_UNORM"

title <nul && color 0a & mode 66,5 & cls <con: ^< nul title "!cd!\Texconv.exe" found^^!! set "_pping=pathping.exe 127.0.0.1 -n -q 1 -p 25" <con: rem./ && pushd "%windir%\system32" && echo\

for /f skip^=3 %%i in ('echo\prompt $h^|cmd')do set "_bs=%%i" title <nul && title Jeffrey Witty %~nx0 batch directory script v0.0.1 for %%i in (" Jeffrey Witty %~nx0 batch directory script v0.0.1 /Beta #" " Texconv.exe is installed # Install path: [ "%~dp0texconv.exe" ] " )do for /f delims^=^ eol^= %%M in ('"(cmd /u /c echo=%%~i)|find /v """' )do if not "%%~M" == "#" ( !_pping! >nul & set /p "=-!_bs!%%~M %_bs%" <nul )else <con: rem./ && !_pping! >nul & set /p "=!_bs!^!!_bs!"!_bs!<nul & echo\

popd && %AppDir%timeout.exe /t 6 >nul & cls & mode 116,16 & echo\ for /f %%i in ('2^>nul where /r "!cd!" "*.tiff"')do set "_dir_out=%%~dpi" && <nul ( call "%~dp0texconv.exe" !_flag! "%%~dpnxi" -o "!_dir_out:~0,-1!" -y )

echo\ & <con: rem./ && echo\ && %AppDir%timeout.exe -1 | echo\ Press any key to continue... endlocal & popd & color 0A & goto :EOF

:error cls & mode 75,9 & <con: pushd "%windir%\system32" echo\ & set "_pping=pathping.exe 127.1 -n -q 1 -p 25" title <nul & <con: ^< nul title ERROR: texconv.exe not found^^!!

color F4 & for /f skip^=3 %%i in ('echo\prompt $h^|cmd')do set "_bs=%%i" for %%i in (" ERROR: texconv.exe not found # Install path: %~dp0Texconv.exe #" "This script needs Texconv.exe in order to work properly #" "Please, make sure Texconv.exe is in: %~dp0" )do for /f delims^=^ eol^= %%M in ('"(cmd /u /c echo=%%~i)|find /v """' )do if not "%%~M" == "#" ( !_pping! >nul & set /p "=-!_bs!%%~M %_bs%" <nul )else <con: rem./ && !_pping! >nul & set /p "=!_bs!^!!_bs!"!_bs!<nul & echo\

echo\ & <con: rem./ && echo\ & %AppDir%timeout.exe -1 | ^ echo\ Press any key to continue... & endlocal & popd & color 0A & goto :EOF


Editing this current code does not result in much use for your question, it is intended for another application other than your goal.

I suggest a specific code for your needs and with some more suggestions ...


Obs.: 1 Command flags changes made to make the conversion work

%@LOGO% -srgb -nogpu -pow2 -vflip -if triangle -bc u -f %@FORMAT% 
%@LOGO% -srgb -nogpu -pow2 -vflip -if triangle -bc u -f %@FORMAT%
-nologo -srgb -gpu 1 -pow2 -vflip -if triangle       -f BC3_UNORM

Obs.: 2

   <adapter>:
      0: VID:8086, PID:5916 - Intel(R) HD Graphics 620
      1: VID:10DE, PID:134D - NVIDIA GeForce 940MX
      2: VID:1414, PID:008C - Microsoft Basic Render Driver

Obs.: 3 For testing and adaptation purposes, I used Microsoft(R) DirectX Texture Converter (DirectXTex version) and this flag -bc u was not available in the version used

Obs.: 4 The current version of Microsoft (R) DirectX Texture Converter (DirectXTex version) has a new flag only to indicate the output in the same folder as the input

enter image description here

Note: The "typewriter" effects/simulator was adapted from that answer from @Compo

Io-oI
  • 9,237