How to list only name and date of documents using the dir (ms dos) command?

-1

Good morning, I need to create a csv file listing only name and date of the files within a given directory, but I could not identify any options of the command dir where I bring only those items, most of them have a header and the size of the files. I'm using it like this

dir "\diretorio_origem\*.pdf"  > \diretorio_destino\lista_arquivos.csv

Thank you!

    
asked by anonymous 18.12.2018 / 14:26

1 answer

0

The command would have to be a dir + a double for :

Direct from the command line:

type nul > \diretorio_destino\lista_arquivos.csv && for /f "tokens=* delims=^ " %a in ('dir /a-h-s-d /c /o-n /b "\diretorio_origem\*.pdf"') do for /f "tokens=1,3 delims= " %A in ('@echo/%~ta %~na') do @echo/%B;%~nxA>>.\diretorio_destino\lista_arquivos.csv

Inside a bat file:

@echo off 
type nul > \diretorio_destino\lista_arquivos.csv 
for /f "tokens=* delims=^ " %%a in ('dir /a-h-s-d /c /o-n /b  "\diretorio_origem\*.pdf"') do for /f "tokens=1,3 delims= " %%A in ('echo/%%~ta %%~fa') do echo/%%B;%%~nA>>.\diretorio_destino\lista_arquivos.csv

I understand that the name is extension , if you want the extension strong> ~nA with nxA .

    
31.12.2018 / 22:43