需要检查文件夹是否使用批处理文件退出 [英] Need to check if Folder exits using batch file

查看:79
本文介绍了需要检查文件夹是否使用批处理文件退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想检查文件夹是否退出或不使用批处理文件,如果退出我想删除该文件夹,否则什么也不做.

文件夹的路径为:%userprofile%\ AppData \ LocalLow \ Dictionary

条件是我需要按批处理文件进行操作.
需要删除所有现有用户的文件夹,任何人都可以帮助我解决此问题.
我尝试了以下代码,但无法正常运行

Hi All,
I want to check if folder exits or not using batch file, if exits i want to delete that folder else do nothing.

Path of the folder is : %userprofile%\AppData\LocalLow\Dictionary

Condition is i need to do it by batch file.
Need to delete folder for all the existing users can anybody help me in solving this.
I tried the below code but not working

SET  src_dir="%userprofile%\AppData\LocalLow\Dictionary"

IF EXIST %src_dir%\NUL
(

rmdir /s /q "%userprofile%\AppData\LocalLow\Dictionary"
) 
ELSE 
(
echo "Not exists"
pause
)


预先感谢您


Thanking you in advance

推荐答案

最简单的建议是:只需删除,您就不会出错.如果该目录不存在,则什么都不会改变.

如果您仍然需要检查,请参阅此旧的Microsoft支持文章,并说明许多其他问题:
http://support.microsoft.com/kb/65994 [ http://www.robvanderwoude.com/allhelp.php [
The simplest suggestion is: with just deleting you cannot go wrong. If the directory does not exist, nothing will change.

If you still need a check, this old Microsoft support article explains the matter, as well as many other sources:
http://support.microsoft.com/kb/65994[^].



You can get full description of all batch command and syntax on your system, if you auto-generate help using this wonderful batch script by Rob van der Woude improved by Johan Parlevliet:
http://www.robvanderwoude.com/allhelp.php[^].

—SA


暂停不是真正必要的
整个代码行应位于批处理文件的一行中,除了"pause"应位于第二行中.

The pause isn’t really necessary
The whole line of code should be on a single line in the batch file except for the "pause" that should be on the second line.

for /d %%a in ("%systemdrive%\Users\*.*") do if exist %%a\AppData\LocalLow\Dictionary rmdir /s /q %%a\AppData\LocalLow\Dictionary
pause


这篇关于需要检查文件夹是否使用批处理文件退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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