Windows BAT : test if a specific file is empty

前端 未结 3 1510
太阳男子
太阳男子 2021-01-05 02:25

I would like to check if a specific file is empty in a windows .bat file. Here is my non working script :

set dir=\"C:\\test\"
set file=\"%dir%\\fff.txt\"

c         


        
3条回答
  •  灰色年华
    2021-01-05 02:56

    Or try it with

    @echo off
    set "dir=C:\temp"
    set "file=%dir%\a.txt"
    
    call :CheckEmpty "%file%"
    goto :eof
    
    :CheckEmpty
    if %~z1 == 0 exit
    ftp -s:"%dir%\ftp.action"
    goto :eof
    

    The main difference is that I use a function call and use the %~z1, as the modifiers only works for paramters like %1, %2..%9 or for-loop parameters like %%a ...

提交回复
热议问题