我如何编辑此 texconv“IMGtoBC3.bat”文件,以便它在写入“结果”dds 文件时“读取并保留目录结构”

我如何编辑此 texconv“IMGtoBC3.bat”文件,以便它在写入“结果”dds 文件时“读取并保留目录结构”

我如何编辑这个 texconv“IMGtoBC3.bat”文件,以便它在写入“结果”dds 文件时“读取并保留目录结构”?

就我个人而言,我有一个很大的文件夹/子文件夹,其中有许多“具有相同文件名”的 tiff,被分成“集合”。

这些 dds 文件用于 Unity 游戏中的自定义纹理,文件命名是强制事件,但按文件夹“排序/选择”。

我有大约 3000 个文件集准备转换,但我不会在 Nvidia 工具中逐个进行转换(我希望如此),而且 AMD 工具和游戏存在严重冲突(这是不行的)

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

答案1

在此处输入图片描述

@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   

编辑当前代码不会对您的问题产生太大用处,它旨在用于除您的目标之外的其他应用程序。

我根据您的需要建议了一个特定的代码,并提出了一些建议......


观察:1命令标记了为使转换工作而做出的更改

%@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

观察: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

观察:3为了测试和适应目的,我使用了 Microsoft(R) DirectX 纹理转换器(DirectXTex 版本),并且此标志-bc u 在所用版本中不可用

观察:4当前版本的 Microsoft (R) DirectX 纹理转换器 (DirectXTex 版本) 有一个新的标志,仅用于指示输出与输入位于同一文件夹中

在此处输入图片描述

笔记:“打字机”效果/模拟器改编自回答@Compo

相关内容