Last active
June 28, 2021 04:52
-
-
Save mnadjit/66c8856285dad44e2476597f737e2e76 to your computer and use it in GitHub Desktop.
This script combines hl7 files - this is to address the limitation in 7edit application which does not show multiple files in batch mode and requires a single batch file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SET UnzipperPATH="C:\Program Files\7-Zip\7z.exe" | |
SET HL7EditorPATH="C:\Program Files\7edit.com\7Edit 2.x\7edit.exe" | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
FOR %%f IN (*.zip) DO ( | |
CALL :Unzip %%~nf | |
SET /P DeleteZip="Delete Zip File? [y/n]: " | |
IF /I !DeleteZip!==y DEL /Q %%~nf.zip | |
) | |
GOTO END | |
:Unzip | |
ECHO Unzipping the following file: | |
ECHO %1 | |
SET /P OUTFOLDER="Output Folder Name? " | |
ECHO %UnzipperPATH% x %1.zip -o %CD%\%OUTFOLDER% | |
%UnzipperPATH% x %1.zip -o"%CD%\%OUTFOLDER%" | |
CD %CD%\%OUTFOLDER%" | |
FOR %%g in (*) DO CALL :RenameFiles %%g | |
CALL :CombineFiles | |
CD .. | |
ECHO. | |
EXIT /B | |
:RenameFiles | |
ECHO Adding .hl7 to the end of the following file name: | |
ECHO Renaming: %1 | |
REN %1 %1.hl7 | |
EXIT /B | |
:CombineFiles | |
SET CombinedFileName=_cmbnd_%OUTFOLDER% | |
ECHO Combining all HL7 files in current folder into one named: %CombinedFileName% | |
FOR %%i IN (*.hl7) DO ( | |
type %%i >> %CombinedFileName% | |
echo. >> %CombinedFileName% | |
) | |
REN %CombinedFileName% %CombinedFileName%.hl7 | |
CALL :CheckForError | |
ECHO Path to HL7 viewer: %HL7EditorPATH% | |
SET /P DORUN="Run with HL7 Viewer? [y/n]: " | |
IF /I %DORUN%==y %HL7EditorPATH% %CD%\%CombinedFileName%.hl7 | |
EXIT /B | |
:CheckForError | |
IF %ERRORLEVEL% EQU 0 ( | |
ECHO *************************** | |
ECHO ********* SUCCESS ********* | |
ECHO *************************** | |
ECHO Successfully combined all HL7 files in current folder into one named: %CombinedFileName%.hl7 | |
) ELSE ( | |
ECHO Something went wrong! | |
GOTO END | |
) | |
EXIT /B | |
:END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment