Windows Batch file to count a set "N" number of files from a single source folder,merged multiple files together into a single output file that contains <= N number of records, and move processed files to a save directory folder.
Request for a window bat file that can be run from command/CMD prompt. Windows 7 environment.
Windows Batch file to copy a set "N" number of files from a single source folder to an output file, move processed records to a single save folder. The single source directory may contain 1 up to a million files.
Need to copy 200 files at a time to a newfile_N+ that should contain <= 200 files per newfile_N+ until all records have been read and processed.
Input file extension: *.hl7
Output file newfile_N+ extension: *.txt
Source directory - C:\temp\source
Destination directory - C:\temp\output\newfile_N+.
Destination directory - C:\temp\processed
For the purpose of demonstration I have attached (5) sample hl7 files.
Each newfile_N+.txt file should contain <= 2 records per file.
Prior to kicking off the batch file. All (5) source files would be all be in the (C:\temp\source) directory.
Upon completion of the batch program running. The expected output once the bat file has run would result in the following:
dir: contains no files *.hl7 files
dir: newfile.txt, newfile1.txt, newfile2.txt
Note: Each of these files contains <=2 records each, max is 2 records per file
==> newfile.txt contains 2 records
==> newfile1.txt contains 2 records
==> newfile2.txt contains 1 record
dir: new 1.hl7, new 2.hl7, new 3.hl7, new 4.hl7, new 5.hl7
Note: This processed directory should contain the records that were originally in the source directory
This is example is using a small # of input/output records. In reality the source directory may hold 1 record or a million.
The ask is that the solution would accommodate and use variables where appropriate.
Note: The folder names may contain spaces, also the file names may contain spaces.