Tuesday, August 10, 2021

How to delete files older than x days in a network drive

When using the forfiles command on network shares, 

the forfiles command can be used to delete files older than x days in a folder 

however, direct use of UNC path may result in the ff error: 

 

"ERROR: UNC Paths <\\machine\share> are not supported."

 

 A solution to this would be to map the network drive (force map)

NET USE O: /delete /y
NET USE O: \\192.168.0.1\yourfolder

forfiles /p "O:\testdelete" /s /m *.* /c "cmd /c Del @path" /d -7 


No comments:

Post a Comment