Glam Prestige Journal

Bright entertainment trends with youth appeal.

I'm making a windows batch script, I need to get the specific size of a file so I can Insert that and other values I already got to a database, but I just can't figure out the proper way to do it.

Assuming the name of the file is c:\test!basename!.zip (I'm in a for loop here), how can I get the filesize and store it to a variable?

The machine is a Win2008 Server.

ANSWER

EliadTech proposed a solution that I've already tried

for %I in (test.jpg) do @echo %~zI

That worked directly in the command prompt, but failed inside the script.

EliadTech, as we already suspected, thought of checking the escaping, so we got this

for %%I in (c:\test\!basename!.zip) do @echo yay %%~zI

Works like a charm.

Kinda dumb mistake, but bash has spoiled me beyond repair :)

1 Answer

There are a few suggestions here. I think this is best suited to you:

for %I in (test.jpg) do @echo %~zI
6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy