Extracting all DIR info into a CSV via DOS: need to understand how to do it
Hi, I need to make a list of a folder's content on a server put this result in a Data filtered Excel file. I only have access to this folder via a mapped drive. This list will be used to identify which files can be migrated to another place, mainly document types of files. I still need to look at the other kinds of files in case we have to migrated them too.
The information I need to fetch are:
- full folder path (foler and subfolders)
- filename
- file extension (to later filter on documents kinds of file and non-documents kind of files) (.doc, .xls, *.ppt, *.pdf, *.txt, ...)
- filesize
- creation date
- last access date
- owner of the file
I found something where through a few DOS command could help me to create a *.CSV output I could then load into Excel. But my knowledge is limited on how to do it and what are all the delimiters I can use to send to the output.
I know for a fact that there are some filenames with illegal characters in them that caused other scanning means to split or shorten the filename.
Can someone help?
@ ECHO OFF
(FOR /f "delims=" %%a IN ('dir /b /a-d') DO (
FOR /f "tokens=1-3*" %%x IN ('dir /a-d /tc "%%~a"^|findstr "^[0-9]"') DO (
ECHO "%%a",%%~ta,%%x %%y %%z
)
)) > DIR.txt
TYPE DIR.txt