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

Size 12

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
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
I just split a 3TB ext HDD in GPT
I bought a Seagate 3 TB external HDD, ($99 at Best Buy for Black Friday!) I copied the Seagate stuff to my hard drive so I could copy it back later. The drive showed up in Win 7 as a full 3 TB NTFS drive. But I wanted two 1.5 TB partitions because I have a bunch of 1.5 TB drives to copy around. I...
Hardware & Devices
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
All on one or split for SSD
Hey peeps, I have been looking at SSD's as i think its about time to upgrade. At the moment i have 3 HDD's (As per my system specs below) The way i have my PC set is WD Caviar Black 500GB for OS and apps WD Caviar Black 750GB for games WD Caviar Blue 500GB for Media
Hardware & Devices

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 08:24.

Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App