批处理文件检查是否存在于驱动器的主分区(cmd语言) [英] batch file to check if exist in the main partition of drive (cmd language)

查看:88
本文介绍了批处理文件检查是否存在于驱动器的主分区(cmd语言)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望批处理文件检查是否存在于主驱动器中

例如

set / p test =输入文件:

if%test%==%drivename%goto fin

if%test%==%drivename%goto end



:fin

回显文件在主分区

暂停

退出

:结束

echo文件不在主分区中

暂停

退出

i want batch file to check if exist in the main drive
for example
set /p test=type the file:
if %test%== %drivename% goto fin
if %test%== %drivename% goto end

:fin
echo the file is in the main partition
pause
exit
:end
echo the file is not in the main partition
pause
exit

推荐答案

这样的事可以做什么你期望吗?

Could something like this do what you expect?
<br />
@echo off<br />
set /P test=type the file:<br />
<br />
call :check_main "%test%"<br />
pause<br />
goto :EOF<br />
<br />
:check_main<br />
if "%~d1" == "%HOMEDRIVE%" (<br />
  echo the file is in the main partition<br />
) else (<br />
  echo the file is not in the main partition<br />
)<br />
goto :EOF<br />





上面的代码片段检查具有给定名称的gile是否位于%HOMEDRIVE%



The snippet above checks, whether a gile with a give name is located on the %HOMEDRIVE%

这篇关于批处理文件检查是否存在于驱动器的主分区(cmd语言)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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