与UNC路径FORFILES [英] forfiles with UNC path

查看:1317
本文介绍了与UNC路径FORFILES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用FORFILES删除都超过7天的文件。该文件是在一个UNC路径。下面是我使用的脚本。

I am trying to use forfiles to delete files that are older than 7 days. The files are in a UNC path. Below is the script that I am using.

Forfiles -p \\devexpress\C$\FULL\ -s -m *.* -d -7 -c "cmd /c del /q @path" 

不过,我得到一个错误提的是UNC路径(\\计算机名\\共享)不支持。

But I get an error mentioning that UNC paths (\machine\share) are not supported.

有看起来可用的解决方法,但不能得到明确的答案的谷歌搜索。

There appears to be workarounds available but cannot get a clear answer googling.

推荐答案

试图重现的问题,当我得到的错误说,问题不在于FORFILES不suporting UNC路径,但使用CMD不能够开始与UNC路径作为默认目录。如果这也是你的问题,有解决这个问题的三种方法。

The error I get when trying to reproduce the problem says that the problem is not with FORFILES not suporting UNC Path, but with CMD not being able to start with an UNC path as default directory. In case that this is also your problem, there are three approaches to solve it.


  1. 您可以分配的UNC路径磁盘代号,通过 NET USE

NET USE V: \\devexpress\C$
Forfiles -p V:\FULL\ -s -m *.* -d -7 -c "cmd /c del /q @path" 


  • 您可能会绕过 CMD 键,直接在 FORFILES

    您可能会绕过 FORFILES ,并使用命令用一些时间检查,而不是逻辑。见我回答这个堆栈溢出问题<一href=\"http://stackoverflow.com/questions/6840156/how-can-i-check-the-time-stamp-creation-of-a-file-in-a-windows-batch-script\">How我可以检查时间戳创建一个文件在Windows批处理脚本?

    You may bypass FORFILES and use FOR command with some date checking logic instead. See my answer to this Stack overflow question How can I check the time stamp creation of a file in a Windows batch script?

    这篇关于与UNC路径FORFILES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆