Copy file contents from Notebad to WordPad

Posted on 2012-08-22
Last Modified: 2012-08-22
I have a text file that has some hidden characters which show up in WordPad, but not in notepad.
When I try to execute a script on my server with this file, it errors out because the line feeds aren't there.

How can I write a batch file which opens the text file and copies all contents, then writes those contents to a WordPad document?
Question by:dimmergeek
    LVL 13

    Expert Comment

    Sorry for not supplying sutch a batch file, but batch files are not the preferred way of doi'n that.

    I would suggest some small piece of software (it's more or less simple to do in VB or C) for that.

    Simple version:

    Read the file in binary mode, say in chunks of about 100 Bytes into an array of char.
    after reading each chunk, go sequentially over the chunk and write every byte to the output file that is printable (ASCII 32-127 & CR, LF, TAB)
    repeat until file completed.

    That way any unwanted characters will be stripped away.
    LVL 7

    Author Comment

    I do not know VBS.
    Can you help with the code?
    LVL 15

    Accepted Solution

    LVL 15

    Expert Comment

    by:Ess Kay
    LVL 15

    Expert Comment

    by:Ess Kay
    what do you mean by 'wordpad file'?

    they both open txt files

    Just open it with wordpad instead of notepad and hit save, so it will keep the wordpad formatting

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Suggested Solutions

    Title # Comments Views Activity
    Sql how to exclude from a table 3 60
    Fibonacci challenge 11 61
    countX 22 48
    Internet Connection Util 8 43
    Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now