sonikro
sonikro

Reputation: 86

Check local-file size before uploading to FTP (Batch File)

I am developing an batch file, that will read all files of extension .dem, and will upload it to my FTP. However, only files with more than 1mb can be uploaded.

My current script is:

(upload_demos.ftp)

open my_ip

username

pass

lcd /D "C:\TF2_Server\tf"

cd SourceTV/

binary

mput *.dem

disconnect

quit

And (move_demo_to_ftp.bat)

ftp -i -s:upload_demos.ftp

cd C:\TF2_Server\tf

del /S *.dem

With these scripts, all *.dem files will be uploaded (Including those with size less than 1mb ).

Can you guys help me check the file-size before uploading (And deleting ? )

Thank you,

Upvotes: 0

Views: 894

Answers (1)

rudicangiotti
rudicangiotti

Reputation: 566

To display the size of a certain file you can use the trick already explained in this question: Windows command for file size only? Then, you can integrate that external .bat file in a for cycle to set the output of a dir /b /a-d command as a variable and so to be sent to the external .bat file. Here is the example:

for /f "delims=^T" %%g in ('dir /b /a-d') do (call file_dimension.bat %%g)

You can also set an if statement inside the for cycle to check if the dimension of the file is less, equal or greater than a certain value.

Upvotes: 0

Related Questions