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 %~zIThat 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 %%~zIWorks 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