Table of Contents
After converting long text into PDF and then copying it from the PDF to Notepad, you may encounter unwanted line breaks. In such cases, I have created a script that can be useful.
Validation Environment
- Windows XP
Script
I wrote it using JScript.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
// Declaration of constants var ForReading = 1; // Read var ForWriting = 2; // Write (overwrite mode) var ForAppending = 8; // Write (append mode) function editFile() { var strFolderPath; var objFileSys; var objInFile; var objOutFile; var strScriptPath; var strRecord; objFileSys = new ActiveXObject("Scripting.FileSystemObject"); strScriptPath = String(WScript.ScriptFullName).replace(WScript.ScriptName,""); try { objInFile = objFileSys.OpenTextFile(strScriptPath + "in.txt", ForReading); objOutFile = objFileSys.OpenTextFile(strScriptPath + "out.txt", ForWriting); do { strRecord = objInFile.ReadLine(); objOutFile.Write(strRecord); } while(objInFile.AtEndOfStream==false); } catch(e) { } finally { objInFile.Close(); objOutFile.Close(); } objFileSys = null; objInFile = null; objOutFile = null; strScriptPath = null; strRecord = null; strFolderPath = null; return 0; } editFile(); ForReading = null; ForWriting = null; ForAppending = null; |
How to Use
First, place the text you want to concatenate into a file named in.txt
. Please put in.txt
in the same folder as the script. Next, create an empty text file called out.txt
. Also, place this file in the same folder as the script.
Then, double-click the script. The contents of in.txt
will be merged into one line and written to out.txt
.
Background
The origin of this script was an attempt to concatenate SQL that appeared in a Microsoft Access error report but was broken across words and lines.