DOS Batch file question...

roscoe

Well-known Member
Joined
Jun 4, 2002
Messages
1,062
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I often have the need to run a stack of txt-based files (random extensions like .txt, .csv, etc) through a search program. That program is a total kludge in that it takes longer to go through the mechanincs of selecting/searching the next file than it does to actually search it. A much faster way would be to merge all the files into a single file. There ways to do this via DOS batch commands, but all that I've found require someone with skill to open and edit the file (to change the file extension) and then run it. The person I'm giving this to won't have that skill.

The ideal solution is to put a shortcut on the desktop and drop all the files (or the containing folder) onto that shortcut and have it recursively merge them

Any ideas here or anyone know a similar board where I can go to ask this?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
A batch file containing this code will:
merge all files in the c:\FilesToMerge folder
into this single text file c:\mergedfiles.txt

Code:
copy \FilestoMerge\*.* \mergedfiles.txt
• Put that code into notepad
• Name the file MergeMyFiles.bat
• Find that file using Windows Explorer
• Double-click it to run the program and merge the files.

Is that something you can work with?
 
Upvote 0
A batch file containing this code will:
merge all files in the c:\FilesToMerge folder
into this single text file c:\mergedfiles.txt

Code:
copy \FilestoMerge\*.* \mergedfiles.txt
• Put that code into notepad
• Name the file MergeMyFiles.bat
• Find that file using Windows Explorer
• Double-click it to run the program and merge the files.

Is that something you can work with?

That's great but the hard coded directory means I have to edit it each time or moved the files.

Thanks
 
Upvote 0
Perhaps if you described all of the constraints, we can work around them.
Apparently, this is the first constraint:
1) Not able to somehow get all of the files into one specific location so they can be easily merged
 
Upvote 0
Sorry, that was an approach I didn't anticipate. But, I found a suitable method. I don't recall what it is (It's at work) but I'm good now. Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top