Question

I have been given a data extract dump from an Oracle DB (cc&b). Each extract comes with a .log file which gives a table def, pk, fk, data types etc. I want to copy all these files in to one. I aware of the MS-Dos command 'copy *.log allinone.txt' My problem is the content of the .log files do not contain the table name; the table name only exists on the file name. I need the table name printed in the allinone.txt file. There are 486 tables so manual is not really ideal. Is there way to Print File Name + Content?

Was it helpful?

Solution

I'm assuming you are really using Windows, and not MS-DOS.

I'm also assuming all the .log files are in the same folder.

No batch file is required. Simply CD to the folder with the log files. Then run the following command:

type *.log >combinedLog.txt 2>&1

The TYPE command will include the file name at the top of each file output when a single command types multiple files. The file name is printed to stderr, so stderr is redirected to stdout (2>&1).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top