Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Convert Unix line ending file to Notepad Compatible

- - - - -

  • Please log in to reply
5 replies to this topic

#1
-X-

-X-

    Member

  • Patrons
  • 2,454 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

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-, 11 December 2013 - 11:28 PM.

[ Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk Posted Image ]
If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


How to remove advertisement from MSFN

#2
ar_seven_am

ar_seven_am

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-January 10
  • OS:Vista Ultimate x64
  • Country: Country Flag

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...


Se7en/Vista Unattended DVD XML Creator and Application Installer
Posted Image
Light Blue Ribbon Campaign for Freedom of Skin

I don't care ur race or religion, all I care u're friend of mine! Life's too short, don't waste ur time for war, PEACE IS NOW!

#3
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,830 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag

 

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



#4
ar_seven_am

ar_seven_am

    Junior

  • Member
  • Pip
  • 62 posts
  • Joined 09-January 10
  • OS:Vista Ultimate x64
  • Country: Country Flag

You are half-wrong. ;)
Notepad does NOT support them, Wordpad does.


ehmmm I see, thx jaclaz
Se7en/Vista Unattended DVD XML Creator and Application Installer
Posted Image
Light Blue Ribbon Campaign for Freedom of Skin

I don't care ur race or religion, all I care u're friend of mine! Life's too short, don't waste ur time for war, PEACE IS NOW!

#5
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,573 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

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"


#6
jumper

jumper

    2014 All-American Masters HJ'er

  • Member
  • PipPipPipPip
  • 501 posts
  • Joined 21-January 11
  • OS:98SE
  • Country: Country Flag
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

Design feedback requested:
IHAtool - IpHlpApi tester; call various functions and report results
--status-> framework is solid; 22 api's fully supported; preview release coming soon
ComDlg32 wrapper - ComDlgEx meets IpHlpApi wrapper
--status-> PrintDlgExW working in latest SumatraPDF 8^)
Future projects: ImportPatcher40 - dialog interface; Kexter - IP40+Ktree+Kexstubs




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users