Windows – Command Prompt output to CSV

batch filecommand linecsvmicrosoft excelwindows

I'm using the forfiles command to list files and folders (included sub folders) which is piped to a text file. My subsequent process requires this output to be in comma delimited format (.csv).

This is the script I'm currently using and would like to update:

forfiles /s /C "cmd /c echo @file @fdate @ftime @isdir" > MyTextOutput.txt

Is it possible to send the output from the forfiles command to a .csv file?

Best Answer

Try this:

forfiles /s /C "cmd /c echo @file, @fdate, @ftime, @isdir" > MyTextOutput.csv

You are telling the OS what to output, just tell it to output commas too.

Related Question