• Advertisement
Sign in to follow this  

About bat files

This topic is 1855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I downloaded nvidia texture tools command line utilites to be able to convert some textures to "bump maps". The problem is that it will take to long to do it by hand for all images, so i tried to automate it with bat, but my knowledge for command line sintaks is limited:

[code]
for %%X in (*.dds) do nvcompress -tonormal %%X %%X_bump.dds
[/code]
Last parameter is out file name.

If i have input images in that directory:
[code]
Image1.dds
Image2.dds
Image3.dds
[/code]

Output will be:
[code]
Image1.dds_bump.dds
Image2.dds_bump.dds
Image3.dds_bump.dds
[/code]

But i want to remove first extension so that output would be:
[code]
Image1_bump.dds
Image2_bump.dds
Image3_bump.dds
[/code]

Help.

Thank you for your time.

EDIT: Solved. Last param should be:
[code]
%%~nX_bump.dds
[/code] Edited by belfegor

Share this post


Link to post
Share on other sites
Advertisement
Windows Vista or later? Learn and use PowerShell. It's seriously amazing:
[code]
get-childitem '*.dds' | foreach-object {
& .\nvcompress -tonormal $_.Name $_.Name "$($_.Name)_bump.dds"
}
[/code]

Works with .NET, so you can load almost every assembly and directly work with it in PowerShell.

</advertisement>

Share this post


Link to post
Share on other sites
[quote name='fastcall22' timestamp='1356030284' post='5012882']
Windows Vista or later? Learn and use PowerShell. It's seriously amazing:
[/quote]

And seriously verbose! It's very painful to use from the command line, but it's great for scripting tasks.

Share this post


Link to post
Share on other sites
[quote name='tstrimple' timestamp='1356038412' post='5012939']
And seriously verbose! It's very painful to use from the command line, but it's great for scripting tasks.
[/quote]
It doesn't need to be verbose; that's what aliases are for:
[code]ls *.dds |%{$a=$_.Name;&.\nvcompress -tonormal $a $a "$($_.FullName)_bump.dds")}[/code]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement