Sorry make that first %%fa %%~na - pasted it wrong:
Main Topics
Browse All TopicsI am in need of a txt file that provides a listing of files with the name archive*.pst*, including the size of the file and the owner. Using the following command, I have been able to get most of what I want, but I would also like the list to include the location of the file. I want the format to be bare, but haven't found a way to include the file location in that format. The command I am currently using: dir archive*.pst* /s /q |find "/" >c:\archive.txt gives me the format I want, but sometimes the owner of the file is listed as BUILTIN\Administrators, so that doesn't tell me who the file belongs to. Having the file location would. I'm looking for a 1-line per entry format so I can pull the file into Excel and sort as necessary. Any help would be appreciated!
Thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
To explain
set output="c:\output.csv"
Creates variable called output with the filename of where you want the output
del %output% 2>NUL
removes the above file, hiding any errors (i.e. if it has been run before (spot the obvious mistake, "t" was missed off it. Without this each line is appended.
for /f "tokens=*" %%a in ('dir /b /s /a-d "C:\*.pst"') do (echo %%~na,%%~dpa,%%~za)>>%output
Run down the output of each line from the dir output above which is bare listing, subdirectories, but don;t show directory names of all *.pst files in that dir. Can easily be "D:\somedir\arc*.pst" or whatever you like. It passes each file in turn to %%a which you can then return the name (%%~na), drive & path (%%~dpa) and size (%%~za). Sadly there is no owner available if you needed that, though I guess they are in the user's home drives or similar?
start excel %output%
As this was a CSV formatted file just put this in for convenience at the end to launch excel with the CSV loade into it. You can remove the line or replace it with notepad %output% to show in notepad if you like.
Steve
Business Accounts
Answer for Membership
by: dragon-itPosted on 2009-10-22 at 07:19:03ID: 25634493
OK. If you use a bare directory listing (/b) and a for command it can show you all this and more (look at the options in for /? towards the end).
e.g.
@Echo off
set output="c:\output.csv"
del %outpu% 2>NUL
for /f "tokens=*" %%a in ('dir /b /s /a-d "C:\*.pst"') do (echo %%fa,%%~dpa,%%~za)>>%output%
start excel %output%
That will output a CSV text file consisting of the
filename,drive & path,file size
Does that help? Can soon re-arrange the format, but when you've got a path in there with spaces best to delimit the file with something.
Steve