当您在包含各种文件的文件夹中运行此脚本时,它会复制文件名并向其添加.txt ext,然后将以下注释放在.txt文件中。
这仅适用于运行脚本的文件夹中的文件。我需要帮助来修改此脚本,以便它适用于该文件夹中的所有文件以及您正在运行它的此文件夹的子文件夹中的所有文件。
这可能吗?
@echo off
for /f "delims=" %%a in ('dir /b /a-d ') do (
echo creating "%%a.txt"
>"%%a.txt" echo This file has been removed to free space on the Shared Drive. Contact Tech Department for Restore queries.
rem to delete all the original files you can un-comment the following line by removing the rem
rem del "%%a"
)
popd
答案 0 :(得分:1)
只需将/s
开关添加到dir命令
答案 1 :(得分:0)
稍微改变一下,这只能处理超过x天(本例中为30天)的文件,我觉得这在你的情况下是有意义的。
@echo off
for /f "delims=" %%a in ('forfiles /S /D -30 /c "cmd /c if @isdir==FALSE echo @path"') do (
echo creating "%%~a.txt"
>"%%~a.txt" echo This file has been removed to free space on the Shared Drive. Contact Tech Department for Restore queries.
rem to delete all the original files you can un-comment the following line by removing the echo
echo del "%%~a"
)
(抱歉,应该是评论,但后来会不可读)