相关文章推荐
潇洒的斑马  ·  matlab surf ...·  9 月前    · 
坚强的伤痕  ·  mongodb 使用mongodump备份 ...·  11 月前    · 
英俊的紫菜  ·  了解ES新特性 - 掘金·  1 年前    · 
逆袭的圣诞树  ·  使用 Preload&Prefetch ...·  1 年前    · 

1.删除文件夹:rd /S /Q (rd /? 可以查看命令参数)

@echo off
rem 删除文件夹
set logPath=D:\tool\DelHisKLineData\log
set dateSuffix=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
rem FCT_INDEX_2
rem sh
set klinepath=D:\Server\FCT_INDEX_2\hqservice\data\sh
rd /S /Q %klinepath%\min1kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min5kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min15kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min30kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min60kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rem sz
set klinepath=D:\Server\FCT_INDEX_2\hqservice\data\sz
rd /S /Q %klinepath%\min1kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min5kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min15kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min30kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min60kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rem 删除文件夹
rem FCT_INDEX
rem sh
set klinepath=D:\Server\FCT_INDEX\hqservice\data\sh
rd /S /Q %klinepath%\min1kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min5kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min15kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min30kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min60kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rem sz
set klinepath=D:\Server\FCT_INDEX\hqservice\data\sz
rd /S /Q %klinepath%\min1kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min5kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min15kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min30kline >> %logPath%\DelHisKLine_%dateSuffix%.txt
rd /S /Q %klinepath%\min60kline >> %logPath%\DelHisKLine_%dateSuffix%.txt

2.删除指定文件:del /F /S /Q

rem 删除文件
rem 查看del命令的参数:del /?
@echo off
setlocal enabledelayedexpansion
rem 变量延迟
set logPath=D:\tool\DelLog\log
set path=D:\app\taf\app_log\IndicatorSys\FormulaCalcServer
set dateSuffix=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
for /r %path% %%i in (*.*) do (
	rem echo 完整路径: %%i
	rem echo 无后缀路径: %%~dpni
	rem echo 所在目录: %%~dpi
	rem echo 完整文件名: %%~nxi
	rem echo 不带后缀文件名: %%~ni
	rem echo 文件后缀: %%~xi
	set filename=%%~nxi
	set filetmp=%%~ni
	echo 文件日期后缀: !filetmp:~-8,8!
	set datetmp=!filetmp:~-8,8!
	if /I !datetmp! LSS %dateSuffix% (
		echo !datetmp!
		echo:
		del /F /S /Q %path%\!filename! >> %logPath%\delLog_%dateSuffix%.txt
	) else (
		echo GEQ
		echo:
rem 右括号和左括号要和else在同行,else两边需要有空格

参见: https://www.yiibai.com/batch_script/batch_script_operators.html

定时删除文件java 定时删除文件批处理_后缀