从共享文件夹windows批处理中删除X个旧日文件

从共享文件夹windows批处理中删除X个旧日文件,windows,file,batch-file,command-line,directory,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"

我想使用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  
您可以这样使用:

(您可以使用
/l
开关首先使用robocopy列出文件,以避免发生事故)

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