How to list only name and date of documents using dir command?

How to generate a csv file listing only name and date of files within a given directory.

Since there is no option in the command dir, which generates me an output with only this data.

Most bring a header and file size.

I'm using was Command:

dir "\\diretorio_origem\*.pdf"  > \\diretorio_destino\lista_arquivos.csv
Author: It Wasn't Me, 2018-12-18

1 answers


  • update : using forfiles to get date and name of files:
forfiles /m *.* /c "cmd /c echo/@fdate;@file"

  • results: 16-04-2019,"Arquivos.ext"

The command could be a dir + a double for, and using the delimiter configured on the system...

Because it happens that a file CVS , has the following layout :

  • dado+delimitador+dado... | getting: | 01/01/2001;nome_arquivo.ext
:: para identificar/ler o delimitador configurado no sistema (para caso o usuário tenha alterado) via linha de comando ::
set _hkey=HKCU\Control Panel\International  & for /f "tokens=3 delims= " %i in ('reg query "%_hkey%" ^| findstr /lc:"sList"') do set _delimitador=%i

:: para identificar o delimator configurado via bat ::
set _hkey=HKCU\Control Panel\International
for /f "tokens=3 delims= " %%i in ('reg query "%_hkey%" ^| findstr /lc:"sList"') do set _delimitador=%%i

:: na linha de comando ::
type nul > \\diretorio_destino\lista_arquivos.csv & set _hkey=HKCU\Control Panel\International  & for /f "tokens=3delims= " %D in ('reg query "%_hkey%" ^| findstr /lc:"sList"')do for /f "tokens=1,5delims= " %i in ('dir /tc /a-d^|find "/"')do echo/%i%D%j>>\\diretorio_destino\lista_arquivos.csv 

:: no arquivo bat ::
type nul > \\diretorio_destino\lista_arquivos.csv & set _hkey=HKCU\Control Panel\International  & for /f "tokens=3delims= " %%D in ('reg query "%_hkey%" ^| findstr /lc:"sList"')do for /f "tokens=1,5delims= " %%i in ('dir /tc /a-d^|find "/"')do echo/%%i%%D%%j>>\\diretorio_destino\lista_arquivos.csv 
  • results: 16/04/2019;Arquivos.ext
 1
Author: It Wasn't Me, 2019-10-09 16:13:30