Batch file needed to sort alpha channel tga files.
Moderator: DosItHelp
Batch file needed to sort alpha channel tga files.
Hi All........
I need a batch file to sort tga image files.
I have Win 7 pro 64 bit.
I have a bunch of tga image files.Some have alpha channels.What I want to do is find a hex string 08 ( zero eight ) and use "goto movethem" as shown in the examples below.There is only one 08 hex string in each of my tga files that have an alpha channel.
The 2 examples below won't work.The first one moves the ones with no alpha channel also.The 2nd one just makes the folder,does nothing else.
Please help.Thanks!
Val
@echo off
md alpha-tgas
findstr /I "08" *.tga
if exist goto movethem
:movethem
move *.tga alpha-tgas
pause
exit /b
@echo off
md alpha-tgas
for /f "eol=: delims=" %%F in ('findstr /m 08 *.tga') do @move "%%F" alpha-tgas >nul
pause
exit /b
I need a batch file to sort tga image files.
I have Win 7 pro 64 bit.
I have a bunch of tga image files.Some have alpha channels.What I want to do is find a hex string 08 ( zero eight ) and use "goto movethem" as shown in the examples below.There is only one 08 hex string in each of my tga files that have an alpha channel.
The 2 examples below won't work.The first one moves the ones with no alpha channel also.The 2nd one just makes the folder,does nothing else.
Please help.Thanks!
Val
@echo off
md alpha-tgas
findstr /I "08" *.tga
if exist goto movethem
:movethem
move *.tga alpha-tgas
pause
exit /b
@echo off
md alpha-tgas
for /f "eol=: delims=" %%F in ('findstr /m 08 *.tga') do @move "%%F" alpha-tgas >nul
pause
exit /b
Re: Batch file needed to sort alpha channel tga files.
.TGA is a binary image file of a bunch of megabytes right? Can you be certain that 08 is an illegal sequence in a .TGA file?
Re: Batch file needed to sort alpha channel tga files.
foxidrive....
Here is a link to a hex image of one of the alpha channel tga files.
Hope that helps.
http://vnovak.com/has1alphachannel.html
Thanks!
Here is a link to a hex image of one of the alpha channel tga files.
Hope that helps.
http://vnovak.com/has1alphachannel.html
Thanks!
Re: Batch file needed to sort alpha channel tga files.
val5662 wrote:foxidrive....
Here is a link to a hex image of one of the alpha channel tga files.
Hope that helps.
http://vnovak.com/has1alphachannel.html
Thanks!
This is a binary file of image data right? http://en.wikipedia.org/wiki/Truevision_TGA
I didn't look closely but I've never seen an image format that doesn't allow any of the entire range of hex values,
and your image only shows a kb or so so I can't tell what other data is in the file.
You're saying that the hex value 08 doesn't exist in any of the image data, only in the header of an alpha channel image
(and I admit that am not familiar with alpha channel image data)
If that is the case then try this:
Code: Select all
@echo off
md "alpha-tgas" 2>nul
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for %%a in (*.tga) do findstr /I "%BS%" "%%a" >nul && move "%%a" "alpha-tgas" >nul
pause
Re: Batch file needed to sort alpha channel tga files.
foxidrive.........
Thanks a lot !
Your code:
worked 100% by moving all the alpha channel tgas and leaving the tga files with no alpha channel alone as those do not have a "08" anywhere.
If you have time , could you explain the basics of how your code worked?
How did the code know to search for "08" ?
What does BS stand for ?
( just a very short explanation is ok )
Thanks again!
I appreciate your help a bunch !
Val
MOD EDIT: PLEASE USE CODE TAGS
Thanks a lot !
Your code:
Code: Select all
@echo off
md "alpha-tgas" 2>nul
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for %%a in (*.tga) do findstr /I "%BS%" "%%a" >nul && move "%%a" "alpha-tgas" >nul
pause
worked 100% by moving all the alpha channel tgas and leaving the tga files with no alpha channel alone as those do not have a "08" anywhere.
If you have time , could you explain the basics of how your code worked?
How did the code know to search for "08" ?
What does BS stand for ?
( just a very short explanation is ok )
Thanks again!
I appreciate your help a bunch !
Val
MOD EDIT: PLEASE USE CODE TAGS
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Batch file needed to sort alpha channel tga files.
val5662 wrote:foxidrive.........
Thanks a lot !
Your code:Code: Select all
@echo off
md "alpha-tgas" 2>nul
:: Define BS to contain a backspace
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for %%a in (*.tga) do findstr /I "%BS%" "%%a" >nul && move "%%a" "alpha-tgas" >nul
pause
worked 100% by moving all the alpha channel tgas and leaving the tga files with no alpha channel alone as those do not have a "08" anywhere.
If you have time , could you explain the basics of how your code worked?
How did the code know to search for "08" ?
What does BS stand for ?
( just a very short explanation is ok )
Thanks again!
I appreciate your help a bunch !
Val
BS is just what he named the variable. He could have called it anything, really; he just went with BS (short for backspace).
This code takes advantage of the fact that the ASCII value of the backspace character is 08. It then searches the TGA file for the backspace character and if it is found, it moves that file to the alpha-tgas directory.
Re: Batch file needed to sort alpha channel tga files.
ShadowThief wrote:BS is just what he named the variable. He could have called it anything, really; he just went with BS (short for backspace).
.
And I thought he was making a Cow Dung reference.
Re: Batch file needed to sort alpha channel tga files.
Thanks all !
Call this problem solved.
echo Topic closed
Val
Call this problem solved.
echo Topic closed
Val
Re: Batch file needed to sort alpha channel tga files.
You can'tval5662 wrote:Thanks all !
Call this problem solved.
echo Topic closed
Val
Code: Select all
call this problem solved
or you'll get a
Code: Select all
file not found
Sorry, bad batch joke.
Glad these guys were able to help you. Your use case is why batch files are so awesome. The execution was probably lightning fast too!