0
\$\begingroup\$

Like the title says:

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

THIS IS FOR END USERS, OF A GAME MOD "EASY CUSTOM ASSET BUILDER"

  • SO I NEED TO ALLOW "MANY" INSTALL LOCATIONS
  • PLUS "ENDLESS" CUSTOM DIRECTORY STRUCTURES OF INPUT FILES inside the "directed to use "folders""

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)

BONUS points to anyone that could show me this "bat" file using unity's new tree of "CRUNCH" cmd line dds compressor/encoder. Suggestions of other tools: I have tested over 50 apps, for my needs its: Nvidia, texconv and then crunch in level of quality/support

HERE IS THE CODE:

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
```
\$\endgroup\$
3
  • 1
    \$\begingroup\$ This looks like a question for Super User. \$\endgroup\$ – DMGregory Oct 7 '20 at 23:32
  • \$\begingroup\$ @DMGregory I summon thee to answer Windows command: M$:/ - unveil -cli (bash script) (MS-DOS commands) (PowerShell script) -o my_mind.md \$\endgroup\$ – Jeffrey Witty Oct 9 '20 at 15:45
  • \$\begingroup\$ I think you'll find more batch / PowerShell advice on Super User. Ask here when you need help with something only a game developer would know about, like realtime rendering or game mechanics or game loop updates. Batch scripts are pretty general, so any Windows expert can help you with that, even if they know nothing about what these texture converter programs do under the hood. \$\endgroup\$ – DMGregory Oct 9 '20 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.