0

I'm using the following directXtex texconv command to convert textures individually

texconv -pow2 -f BC1_UNORM cat.jpg

However I'd like to convert a whole folder full of textures. I'm told I need to loop through all textures feeding them in to texconv.exe. How can I do this in the Windows command prompt?

There are other similar questions to this, however this answer can be run within the command prompt, whereas my question is likely to require an external batch file - possibly because it is dealing with jpeg files. I don't know how to set this up

Community
  • 1
  • 1
edward
  • 55
  • 6
  • possible duplicate of [How to loop through files matching wildcard in batch file](http://stackoverflow.com/questions/39615/how-to-loop-through-files-matching-wildcard-in-batch-file) – Michael Sep 17 '15 at 10:55
  • The context is different, and as such I can't see how it applies to my question: There using two files on an in and out exe whereas I have one exe and 100s of textures – edward Sep 17 '15 at 11:18
  • Perhaps you misunderstood what the suggested solution to the question I linked to does. It iterates over all files with a certain file ending, and executes a program for each such file. The fact that it also executes another program for a file with the same name but a different file ending is irrelevant, and something you can just ignore. – Michael Sep 17 '15 at 11:28
  • so how exactly do i adapt `for %%f in (*.in) do ( echo %%~nf process_in "%%~nf.in" process_out "%%~nf.out" )` to be used to process my images using **texconv.exe**? Im guessing I need to replace: *1* `*.in` with `*.jpg` ? *2* `process_in` with `texconv`. *However* I cant work out what to replace `%%f in` with - is this just a variable or referencing to `f.in` which in *my case is different?* Im a newby, thanks for your patience – edward Sep 17 '15 at 12:27
  • `%%f` would be the name of the current jpg file. So `texconv -pow2 -f BC1_UNORM %%f` should do, if you want to use the same options for every file. – Michael Sep 17 '15 at 12:38
  • `for texconv -pow2 -f BC1_UNORM %%f in (*.jpg) do ( echo %%~nf texconv "%%~nf.in" )` produces [texconv was unexpected at this time](http://i.imgur.com/lU6ykc9.jpg) – edward Sep 17 '15 at 12:50
  • `for %%f in (*.in) do ( texconv -pow2 -f BC1_UNORM %%f )` – Michael Sep 17 '15 at 12:52
  • pasting your code in the CMD produces "%%f was unexpected at this time."? – edward Sep 17 '15 at 13:08
  • Put it in a .bat file instead (and obviously `*.in` should've been `*.jpg`). – Michael Sep 17 '15 at 13:11
  • that worked [very nicely indeed](http://i.imgur.com/tgBcBZK.jpg) thank you very much. Perhaps my initial question wasn't as comprehensive as it could of been, i can edit it to highlight the fact we had to use a .bat file and other things? Then you can put your comments as an answer and i can tick off for you? – edward Sep 17 '15 at 13:32

0 Answers0