@echo off for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( if exist %%a:\ ( ::Delete the specified file in "drive letter:\" del "%%a:\Soft.exe" /f /q 2>nul for /d %%b in (%%a:\*) do ( ::Delete the specified file in "Drive Letter:\First Level Folder" del "%%b\Soft.exe" /f /q 2>nul ::Delete the specified file in "Drive Letter:\First Level Folder\Second Level Folder" for /d %%c in ("%%b\*") do del "%%c\Soft.exe" /f /q 2>nul ) ) ) pause
@echo off for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( ::Delete specified files in all subdirectories if exist "%%a:\" del "%%a:\Soft.exe" /s /f /q 2>nul ) pause
Reprinted at: http://www.bathome.net/thread-35465-1-1.html
Delete files before the specified date
@ echo off forfiles /p .\ /s /m file*.* /d -3 /c "cmd /c echo @file>>.\del.txt" forfiles /p .\ /s /m file*.* /d -3 /c "cmd /c del @path" pause
/p specifies the directory .\ is the current directory or you can specify a specific directory such as:
forfiles /p “C:\Users\administrator\Desktop\test”
/s recurse to subdirectories
/m Search for the file name to be deleted, the default is .
/d -3 means 3 days ago
/c means to execute the command to be executed, which needs to be enclosed by "", such as "cmd /c del" means to execute the del command of cmd
Return the file name.
Return the file name without extension.
Only the extension of the file is returned.
Returns the full path of the file.
Returns the relative path of the file.
If the file type is a directory, return "TRUE";
If it is a file, "FALSE" is returned.
Returns the file size in bytes.
Returns the date when the file was last modified.
Returns the time when the file was last modified.
Reprinted at: https://www.cnblogs.com/joeshang/p/10487154.html