窗户BAT:测试,如果一个特定的文件是空的 [英] Windows BAT : test if a specific file is empty

查看:105
本文介绍了窗户BAT:测试,如果一个特定的文件是空的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一个特定的文件是在Windows .bat文件是空的。这里是我的非工作脚本:

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"

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

能不能帮我调试这个好吗?

Could you help me debug this please ?

推荐答案

或者以

@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 paramters,%2 ..%9或环样%%一个参数...

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 ...

这篇关于窗户BAT:测试,如果一个特定的文件是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆