I am running the following command in cmd.exe to list files recursively...
for /r %i in (*) do @echo %~xi %~zi %~ti %~fi
.. to get output like this:
.ext 187392 15/01/2014 14:16 C:\path\to\filename\f.ext
But can I get the file owner added to this output? I'm looking for the same owner that dir /q
gives me. I'd also like to get the file creation time rather than the last-access time which I believe %~ti
is giving me.
If I can't do this using for, is there a way I can do it using a combination of for
and dir
?
< lang-dos -->
@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
for /r "%sourcedir%" %%i in (*.pdf) do (
SET "grab="
FOR /f "skip=5tokens=1,2,4delims=\ " %%a IN ('dir /q /tc /-c "%%~fi"') DO IF NOT DEFINED grab (
SET grab=Y
echo %%~xi %%~zi %%a %%b %%c %%~fi
)
)
GOTO :eof
You would need to change the setting of sourcedir
to suit your circumstances. I used a filemask of *.pdf
to make the test results more legible. You want different? Change it!