Reputation: 82291
I have the following batch file (saved in a file):
@echo off
for /r %%F in (*.png) do (
echo "%%~nF%%~xF" %%~zF
)
I run this and it will print out this result:
"MyFile1.png" 16330
"MyFile2.png" 26042
"MyFile3.png" 43346
"MyFile4.png" 47862
"MyFile5.png" 318131
I want to change this to filter out all the large files (the number is the size in bytes). So as a test I tried this:
@echo off
for /r %%F in (*.png) do (
echo "%%~nF%%~xF" %%~zF
if %%~zF gtr 100000
Echo Is BIG
)
Thinking it would print "Is Big" after the last item in the list.
But Instead I got:
The syntax of the command is incorrect.
Is it possible to compare with an If
statement to a loop variable?
Or is there some other way to get all files over a specific size?
In the end, I am looking for something like this:
@echo off
for /r %%F in (*.png) do (
if %%~zF gtr 100000
Resize %%F by .5
)
(NOTE: The Resize line is pseudo, I don't have that part created yet.)
Upvotes: 1
Views: 541
Reputation: 57242
@echo off
for /r %%F in (*.png) do (
echo "%%~nF%%~xF" %%~zF
if %%~zF gtr 100000 (
Echo Is BIG
)
)
or
@echo off
for /r %%F in (*.png) do (
echo "%%~nF%%~xF" %%~zF
if %%~zF gtr 100000 Echo Is BIG
)
the next line in batch is other command so without brackets or without a command IF is incomplete.
Upvotes: 1