• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
Guest

Convert Unix line ending file to Notepad Compatible

6 posts in this topic

I'm sick and tired of dealing with Unix line endings on readmes and the likes so I did a quick lookup and found the following on Wikipedia though it's been modified by me.

TYPE "%1" | FIND "" /V > "%1".cleaned.txt && del "%1"

It's currently in a batch file shortcut on my sendto menu but I'll put it as an extended context menu item in the end.

Anyways, I don't have time for this. :angel

Please some of you guys are gurus when it comes to this. Just spit out a quick and dirty correct way of doing the command. It happens with .JS, .TXT, .MD (Google Chrome readmes and crap), files just name LICENSE, AUTHORS, NEWS, CONRIBUTERS, etc.

I'd like it to process a UNIX line break file, convert it to DOS terminators CR/LF, delete the original file and then rename the ???temp file??? back to the original filename.

Yeah, I could research some more but I'm just super busy and thought I'd throw this out. I got a lot going on in "RL" ATM so sorry in advance for such a request.

Edited by -X-
0

Share this post


Link to post
Share on other sites

UNIX new line using this :

\n

while CR/LF using this :

\r\n

why do u need to convert since UNIX line break has already supported in Windows? (please correct me if i'm wrong)

with php, I use "str_replace" dont know with cmd prompt for similar function...

0

Share this post


Link to post
Share on other sites

why do u need to convert since UNIX line break has already supported in Windows? (please correct me if i'm wrong)

You are half-wrong. ;)

Notepad does NOT support them, Wordpad does.

@-X-

The "TYPE" trick may have issues, depending on source, it would be much more logical to use a program to replace the CR with CR+LF writing to the same file.

You can use a "dedicated" tool like CRLF by Horst Schaeffer:

http://www.horstmuc.de/horst.htm

or a generic tool, like SED or gsar.

As hinted before it would make even more sense to use an editor that understands the *nix line termination and displays them properly.

jaclaz

0

Share this post


Link to post
Share on other sites

You are half-wrong. ;)

Notepad does NOT support them, Wordpad does.

ehmmm I see, thx jaclaz

0

Share this post


Link to post
Share on other sites

I seem to recall, (many moons ago), something like this working:

@more filename.ext>newfilename.ext@del filename.ext@ren newfilename.ext filename.ext

Therefore you may be able to use:

more "%~1">"%~dpn1.cleaned%~x1" && del "%~1"
0

Share this post


Link to post
Share on other sites

In Win98, MORE doesn't convert the EOL, but SORT does. Using the pipe as the temporary file, this works (without sorting!):

type %1 | sort /+-1 > %1
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.