gpt4 book ai didi

Windows BAT : test if a specific file is empty

转载 作者:可可西里 更新时间:2023-11-01 12:46:23 26 4
gpt4 key购买 nike

我想检查 windows .bat 文件中的特定文件是否为空。这是我的非工作脚本:

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

cd %dir%
if %file%%~zi == 0 exit
ftp -s:"%dir%\ftp.action"
exit

你能帮我调试一下吗?

最佳答案

或者试试

@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

主要区别在于我使用函数调用并使用 %~z1,因为修饰符仅适用于 %1、%2..%9 等参数或 %%a 等 for 循环参数 ...

关于 Windows BAT : test if a specific file is empty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5483960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com