windows下批处理删除文件夹、删除文件、if exist用法
开发中用到Window批处理del、rd、if exist,总结用法便于后续使用。
- windows下批处理删除文件:
* 使用del指令,del /d 文件名:
if exist *.elf del /q *.elf
- windows下批处理删除文件夹:
使用rd指令,rd /s /q 文件夹路径
* 直接使用文件夹路径名:
if exist D:\test4 rd /s /q D:\test4
* 或者文件夹路径使用赋值给了某变量:
if exist ${checkout_local_path} rd /s /q ${checkout_local_path}
- window下批处理if exist的用法,有几个点需要注意:
if exist ${checkout_local_path} (
echo ${checkout_local_path}'s output folder aleady exist.
) else (
echo can't find ${checkout_local_path}'s output folder,will create it.
mkdir ${checkout_local_path}
)
注意这里是有格式的,如下图: