forfiles with UNC path

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" 

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.


Enhanced solution to the PA's first answer is:

PushD "\\devexpress\C$\FULL\" &&(
    forfiles -s -m *.* -d -7 -c "cmd /c del /q @path" 
     ) & PopD

The PushD command maps the UNC path to free drive letter automatically, so this is portable approach. Found in http://www.petri.co.il/forums/showthread.php?t=24241.


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. you might assign the UNC path to a disk letter, via NET USE

    NET USE V: \\devexpress\C$
    Forfiles -p V:\FULL\ -s -m *.* -d -7 -c "cmd /c del /q @path" 
    
  2. You may bypass CMD and directly use some ERASEFILE executable utility directly in the -C option of the FORFILES

  3. 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?