简体   繁体   English

从共享文件夹Windows批处理中删除X个较早的文件

[英]Delete X olderdays Files from Shared Folder windows batch

I want to delete 15 days old files from the shared folder using windows command line , 我想使用Windows命令行从共享文件夹中删除15天的旧文件,

Example :: 范例::

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  

You can use robocopy like this: 您可以这样使用robocopy

(You can use the /l switch to first list the files with robocopy to avoid accidents) (您可以使用/l开关先使用robocopy列出文件,以免发生意外)

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

Source . 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM