سؤال

I'm trying to clean up a network folder and to do so I want to get the last modified and who created for the directory. So far I've found:

dir \\server\share /Q

and that works great showing the owner but it sorts the file or sub directory alphabetically. How can I get the last modified and then sort by that?

And is there a way to export each column to a CSV file? I tried:

echo > folder_owners.csv
echo >> folder_owners.csv
dir \\server\share /Q >> folder_owners.csv

but that seems to randomly seperate things, and only into 1 or 2 columns.

I have found this post but I don't feel like it's exactly what I'm looking for.

Any help would be greatly appreciated.

هل كانت مفيدة؟

المحلول

Use:

DIR \\server\share /Q /O-D /TW /AD

To separate columns, FOR must be used:

FOR /F "TOKENS=1-4,* SKIP=4" %a IN ('DIR \\server\share /Q /O-D /TW /AD') DO (
    ECHO Date time: %a %b
    ECHO     Owner: %d
    ECHO  Filename: %e
    ECHO.
)

Note this will also parse footer...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top