Copy or Export Windows Files to Excel Per Column using Command Line
Use the .txt version as you described:
dir > export.txt
Then, open Excel and from within excel open the file (Ctrl-O, or File/Open from the ribbon), making sure to set the Type to All Files (*.*)
. Don't open the file by dragging it from file explorer.
When you select the file from the File Open dialog box, Excel should respond by displaying the 'Text Import Wizard'. On this wizard, select Fixed width as the Original data type, and then click the Next button.
In step 2, the wizard should open a Data preview window which by default will put the output from the dir
command into a columnar structure. It seems to get it mostly right, but puts the time of day indicator (AM/PM) into a separate column than the time itself.
Removing the separator between these two columns (merging them into 1 column) is done by double-clicking the arrow head at the top of the column line.
After clicking Next to proceed to stage 3 of the wizard, you'll want to ensure the first column has a data format of Date (DMY in my case, MDY in yours). Hit finish and the file list data should be imported with a separate column for date, time, whether the file is a directory, filesize, and filename.
Related videos on Youtube
rickyProgrammer
Updated on September 18, 2022Comments
-
rickyProgrammer almost 2 years
I need to copy the whole content of Windows Files into Excel Document. Below is the example Image of the Windows Explorer containing the files to be exported
Using Command Prompt
I do this line to copy the files but it is not copying or being exported per column
dir > export.xls
I also tried exporting it first to .txt and just copy but still output
dir > export.txt
Here's the result
expected output is it to be exported per column.
-
Admin over 7 yearsJust to clarify; do you want to important the content of the files into Excel or just the timestamps and filenames?
-
Admin over 7 yearsnot the content of each file, just the file name and other information such as size, date modified... in per column way, as you can see in what I have, i can export it but in one column all
-
Admin over 7 yearsYou might find that Powershell can do what you want for a directory, E.g dir | select-object PSChildName, FullName | export-csv -NoTypeInformation export.csv To see all the columns available: dir | export-csv exportraw.csv
-
-
rickyProgrammer over 7 yearsthis works I have question though
-
mcalex over 7 yearsWhat's the question?
-
rickyProgrammer over 7 yearsput it in another question superuser.com/questions/1178997/…