Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Making Forfiles.exe handle source paths with spaces..

$
0
0

Trying to run a batch file to clean up backed up .pst files that are older than 30 days on a 2012 R2 server. I found some syntax that will echo the path to the pst files in question. It works as expected.

forfiles /p D:\ServerFolders\ /s /m *.pst /c "cmd /c echo @file is a pst data file"

But I need to narrow down the source path for the files and ultimately delete any pst files that are older than X number of days. 

The first issue I hit is the fact that there are multiple spaces in multiple folder names in the source path for example:

 D:\ServerFolders\File History Backups\

 I first tried double quoting "" the path which works in my Windows7 Home Premium- laptop and below, but not on server 2012.  When I use them it complains about variables that are used in the command section of the line above. I then tried to use a hex equivalent ^0x22 for the double quote,  it just ignores them as if they weren't there.  I later tried using 8.3 folder names and could get it to work on a Windows 8.1 pro PC, but I could find the short names on the 2012 server.. I would like to make Forfiles read a path with spaces in the folder names so I can narrow the search for pst  files to so I can delete them..

Thanks

Patrick


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>