从共享文件夹窗口批处理中删除X旧日文件

时间:2014-06-20 14:02:34

标签: windows file batch-file command-line directory

我想使用Windows命令行

从共享文件夹中删除15天的文件

示例::

Set Shared_root=\\server\folder /* Does not work for this input , how can i make this work ?*/

Set shared_root=c:\folder     /*Works for this input */

FORFILES /p %shared_root% /d -15 /c "cmd /c ECHO /S /Q @path" >NUL 2>&1  

1 个答案:

答案 0 :(得分:0)

您可以像这样使用robocopy

(您可以使用/l开关首先列出带有robocopy的文件以避免发生意外)

C:\> set _robodel=%TEMP%\~robodel
C:\> MD %_robodel%
C:\> ROBOCOPY "C:\source_folder" %_robodel% /move /minage:15
C:\> del %_robodel% /q

Source