Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Split a txt file \n ?

12 Jun 2016   #1

windows xp c86
Split a txt file \n ?

want to split a txt file.First i open the txt file with notepad++ and i change from this \r\n to this \n , then i want to split them in 1o pieces and for that i use a tool called split or joinand also this script and when i check them i see are \r\n\ again.How to split a txt file \n and keep same \n ?
thanks guys
ur the besttt

SET "sourcedir=C:\Documents and Settings\Admin\Desktop\split files"
SET /a fcount=100
SET /a llimit=10000
SET /a lcount=%llimit%
FOR /f "usebackqdelims=" %%a IN ("%sourcedir%\list.txt") DO (
 CALL :select
 FOR /f "tokens=1*delims==" %%b IN ('set dfile') DO IF /i "%%b"=="dfile" >>"%%c" ECHO(%%a
SET /a lcount+=1
IF %lcount% lss %llimit% GOTO :EOF
SET /a lcount=0
SET /a fcount+=1
SET "dfile=%sourcedir%\file%fcount:~-2%.txt"

My System SpecsSystem Spec
13 Jun 2016   #2

Windows 10 x64

Windows tools like to end lines with \r\n. This behavior extend back through more than three decades of Windows and DOS history. The \r is pointless, useless, and annoying. But it's there.

Unix/Linux uses only \n at line-end. Smart.

Question: Why do you need to need to remove the \r characters? You're showing a .bat script, meant to work in Windows, which wants (and expects) the \r\n line endings.

Nevertheless, if you really must remove the \r characters, get a Linux environment. I use Cygwin. It runs NATIVELY on Windows. It's from Red Hat and it's free. You get the a complete Linux-like environment, suitable for doing your \r-killing work ... and it will do much more.

I can be installed to produce files in a Windows-sh \r\n manner. But that's silly. Instead, during installation choose the more natural Unix/Linux \n behavior.

If you can find the "d2u" dos-to-unix command online, use it to eliminate the \r\n endings:
d2u <inputfile >outputfile
You can also do the reverse (change \n to \r\n) using the "u2d" unix-to-dos command.

If you cannot find the d2u command, you can instead use the "tr" translate command:
tr -d "\r" <inputfile >outputfile
This will simply remove all \r characters.
My System SpecsSystem Spec

 Split a txt file \n ?

Thread Tools

Similar help and support threads
Thread Forum
Possible to split one BIG excel file in MANY separate ones?
Hello, I am looking for a way to split my BIG excel file (2000 rows x 60 columns) into a number of smaller ones. But... in such a way that the forumulas of each file are still 'related', so if i modify one cell, the results should be changed in all the 'related' cells in all other...
Microsoft Office
Error restoring split image file
I created a image file using Imagex, then used Imagex to split the file into 3.5GB chunks, then burned those to individual DVDs. Now when I try to restore them I get an error: The specified image file did not contain a resource selection I have tried both: imagex /apply f:\image.swm 1 c:...
Installation & Setup
How to split 1 mp3 file to 2?
I have an mp3 file that, although it says 1 file, is comprised of 2 individual meditation tapes. These individuals are separate (FLAC) files on the CD's shipped but for whatever reason they're combined on the download into 1 mp3. Although I can copy a FLAC file to the drive and convert it to...
Music, Pictures & Video
How-to Split STR From Movies MKV File ?
I Need to Watch In Splash Pro EX But.. Problems With Subtitle. It Not Show. Now I Can Select Sound Only
General Discussion
Software to cut/split MTS file without re-encoding?
What software would you recommend to cut/split a MTS file without re-encoding?
Music, Pictures & Video

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:37.
Twitter Facebook Google+