Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to display file names, in text file, from shared folder which are older than 4 days.
I can not pass username and password of production server to batch command to access shared folder.

What I have tried:

1) FORFILES /P \\Test\abc /D -4 /S /C "cmd /c if @isdir==FALSE echo /F /Q @path"
On running above command, I am getting an error :
ERROR: UNC paths (\\machine\share) are not supported.

2) dir "\\Test\abc" /b /s > fileslist.txt
In above command, there is no provision to pass D -4 i.e. to get files which are older than 4 days.
Posted
Updated 5-Apr-19 6:21am

If you want to stick with a batch file, then I'd suggest using pushd and popd to connect to the UNC path:
pushd | Microsoft Docs[^]
popd | Microsoft Docs[^]
pushd \\Test\abc
forfiles /D -4 /S /C "cmd /c if @isdir==FALSE echo /F /Q @path"
popd
 
Share this answer
 
Comments
Member 9346617 9-Apr-19 1:11am    
Thanks Richard. It worked for me.
Use the FileSystemObject - reference FileSystemObject object | Microsoft Docs[^]
You can then get hold of the last modified date and use that e.g.
Set FSO = CreateObject("Scripting.FileSystemObject")
set oFile = FSO.GetFile(sFile)

wscript.echo "File last modified: " &  objFile.DateLastModified


Edit … found the Credit: File Modified Date (VBScript)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900