Solved

Carriage Return in Batch File

Posted on 2016-12-01
5
40 Views
Last Modified: 2016-12-01
I need to create a batch file that gets rid of the carriage return. The delimiter looks like a square [].

I attached what the file looks like and highlighted what I see the carriage return as and also another file what the expected output is ..

Any ideas how this can be accomplished
carriage-return.PNG
carriage-return---how-it-should-look.PNG
0
Comment
Question by:Shalver
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Bill Prew
ID: 41909304
Two things to try and see if it helps.  Either:

type filein.txt > fileout.txt

or

more filein.txt > fileout.txt

~bp
0
 

Author Comment

by:Shalver
ID: 41909311
I started something like this but it definitely is not correct !!!

@echo off
    setlocal enableextensions disabledelayedexpansion

    set "first=1"
    <nul (
      for /f "usebackq delims=" %%a in ("Carfinance2.txt") do (
        if defined first (set /p ".=%%a" & set "first=") else (set /p ".=,%%a")
      )
    ) >"output.txt"
0
 
LVL 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 41909323
One other approach you can try is the following in a BAT script, although only if the first post I made doesn't.

If nothing suggested works then upload a sample of the file please.

for /f "tokens=*" %%A in ('type filein.txt') do (for /f "tokens=*" %%B in ("%%A") do (echo.%%B>>fileout.txt))

Open in new window

~bp
0
 

Author Closing Comment

by:Shalver
ID: 41909324
This solution worked ! Thank you very much
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 41909332
Welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

862 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

23 Experts available now in Live!

Get 1:1 Help Now