Friday, October 28, 2011

CMD Print DIR to text file

dir > print.txt

The ">" symbol is telling to put the output of the command to whatever is next. In this case "print.txt". This is useful for writing any output to a file in a script or whatever.

Example: dir > %USERPROFILE%\Desktop\print.txt

This example will print the directory listing to print.txt on your desktop.

Other flags:

dir /b file names only

dir /s include all sub folders & files

Original source: http://www.computerhope.com/issues/ch000772.htm

Actually I really like that site, and spent some time taking their quiz. Entertaining.

Sunday, October 23, 2011

CMD combine CSV files into one

I had the need to combine several CSV (excel) files into one file. The set was long enough that even opening them and copy/pasting would take over an hour. This little trick will do it in a few seconds. (in windows)

1. Put all of your files in the same folder. They all need to be CSV format and should be the only CSV files in the folder. You may want to remove headers from your spreadsheets if you don't want them later.
2. Open a command prompt. Windows+R > cmd This should be the normal command prompt because it doesn't work in powershell.
3. Navigate to the folder with your .csv files
4. type "copy *.csv newfilename.csv"
5. A new file named "newfilename.csv" will show up in the same folder. If you wanted to copy it somewhere else you could run copy *.csv path\newfilename.csv.

Example: copy *.csv %USERPROFILE%\Desktop\newfile.csv




















This will copy all the CSV files from the folder you are in to a file on your desktop named newfile.csv. 


I'm sure this can also be done with any type of text-only file.

If you need to do it on another type of spreadsheet file, you'll want to save copies as CSV first.

Note: if you run this more than once, you will want to delete or move the newly created file before running again. Otherwise the new file will be copied in with the rest and you'll have a lot of duplicates.


I think this is where I found the original answer.
http://www.pcreview.co.uk/forums/do-you-combine-multiple-csv-files-into-one-file-t1739041.html