A way to convert Mac .txt files to Windows .txt files

Joined
Nov 27, 2006
Messages
440
Reaction score
52
Points
28
Your Mac's Specs
Power Mac G5 Dual 1.8 GHz
I know there aren't 2 types of TXT files, one for OS X, one for Windows.
I know there's only one type of TXT.

However, there is one little but quite significant difference between plain text files made in the two OSs:

In Windows, line breaks are \r\n
In OS X, they're \n

As a result,
while TXT files created in Windows will display correctly in OS X,
TXT files created in OS X will be missing all the line breaks when opened in Windows.
(Basically, all the text is displayed on 1 line.)


So does anyone know of a way to convert all the \n to \r\n in a TXT?


note:
I am aware of pseudo-solutions, such as using other formats instead (such as DOC),
which display the line breaks correctly in both OSs,
but still, I'd rather be able to use TXT files between the 2 OSs.
 

eric


Retired Staff
Joined
Nov 4, 2006
Messages
8,704
Reaction score
447
Points
83
Location
twin cities, mn, usa
that's odd...

i haven't noticed that, but probably because i go xp > os x pretty much all the time rather than the other way.

certainly worth investigating!
 
OP
R
Joined
Nov 27, 2006
Messages
440
Reaction score
52
Points
28
Your Mac's Specs
Power Mac G5 Dual 1.8 GHz
I think most people don't notice this because by default, TextEdit is in RTF mode.
(I believe line breaks in RTFs are also OK between the 2 OSs; I know for sure it's the case with DOCs.)

I set it to TXT mode because I don't want/need fancy shmancy formatting when I use TextEdit; I just want plain text.

Characters, tabs, line breaks... that's all.

Keeps the file size as small as possible too.
 

eric


Retired Staff
Joined
Nov 4, 2006
Messages
8,704
Reaction score
447
Points
83
Location
twin cities, mn, usa
ah. not that that would be my issue, i use smultron on os x and textpad on windows. pretty sure they're both basic text only. i think i just must not have opened and os x native text docs on my work machine yet...

ooh! maybe i have some on the ext drive in my bag! i'll have to check.

edit: nope. only music and image files.
 

dtravis7


Retired Staff
Joined
Jan 4, 2005
Messages
30,133
Reaction score
703
Points
113
Location
Modesto, Ca.
Your Mac's Specs
MacMini M-1 MacOS Monterey, iMac 2010 27"Quad I7 , MBPLate2011, iPad Pro10.5", iPhoneSE
TextWrangler should work fine. I will give it a try and get back to you. I have my TextEdit set to .txt also and RTF turned off.

Give Textwrangler a try. It's free.
 
OP
R
Joined
Nov 27, 2006
Messages
440
Reaction score
52
Points
28
Your Mac's Specs
Power Mac G5 Dual 1.8 GHz
TextWrangler seems to do the trick!

Just to make sure I'm not mistaken, I'm basically supposed do this to convert a OS X-made file's line breaks:

-Open in TextWrangler
-Save As
-Click "Options..." at the bottom
-Change "Line Breaks" from "Unix" to "DOS"
-OK
-Save

Is this correct?


BTW,
is there a way to make it such that:

-new files made by TextWrangler are "regular" TXT files (just like those made by TextEdit),
and not the file kind "TextWrangler text file" (and with the TextWrangler document icon)?
-new files made by TextWrangler have the ".txt" extensions by default?


Thanks to all!
 

dtravis7


Retired Staff
Joined
Jan 4, 2005
Messages
30,133
Reaction score
703
Points
113
Location
Modesto, Ca.
Your Mac's Specs
MacMini M-1 MacOS Monterey, iMac 2010 27"Quad I7 , MBPLate2011, iPad Pro10.5", iPhoneSE
TextWrangler ... just supplying the link, since dtravis seems a bit lazy today :) ;)

:D

dtravis7 was waiting to be sure it would work before saying more. Been so busy I have not even had the time to test it. Glad it works for you.
 
Joined
Feb 13, 2005
Messages
1,186
Reaction score
73
Points
48
Location
New Orleans, LA, USA
Your Mac's Specs
13" Macbook Pro 2.26Ghz Unibody 4G RAM 160G HDD Superdrive
This is also why I use command line utilities for both OS's, and this is something that goes back to the early days of all the UNIX's and the DOS world.

You'll note that if you use vi on a text file created by a Windows notepad, for example, will show ^M characters at each newline, while text files created by Mac OS X will look all goofy using windows notepad. Oddly enough, if you edit a text file created by Mac OS X with the "DOS" command line 'edit' command under Windows and just save it, it'll convert the newlines to what Windows expects with the rest of the Windows text editors.

Over on the Mac side, TextEdit generally seems to handle text files properly regardless of where they are created, but vi will show those 'crlf' characters as a ^M, which is not a big deal, but annoying. The vi command line way I deal with this is:

:%s/'control-v''control-m'//

and they will be be converted to 'cr' (carriage return, not carriage return-linefeed) and when you save the file it'll be all well in the UNIX world.

This is probably all confusing to non-UNIX geeks, but this is something I've had to deal with for the entire 20+ years I've been dealing with text between DOS and UNIX. It's real fun when you have thousands of text scripts that have to be ported across OSes and have to figure out what program can best be used to batch convert them all.
 
Joined
Mar 30, 2004
Messages
4,744
Reaction score
381
Points
83
Location
USA
Your Mac's Specs
12" Apple PowerBook G4 (1.5GHz)
...
BTW,
is there a way to make it such that:

-new files made by TextWrangler are "regular" TXT files (just like those made by TextEdit),
and not the file kind "TextWrangler text file" (and with the TextWrangler document icon)?
They are plain ASCII text files, just like those from TextEdit. However, they have a creator code that assign them to open in TextWrangler, which means they carry a TextWrangler icon. Other files on your system may have a TextEdit creator code, so they will sow a TextEdit icon and open in TextEdit by default.

In the same vein, you can have, for example, Photoshop JPEGS, Preview JPEGs, and GraphicConverter JPEGs, even though they are all the same format. Macs can assign the file types to different applications on a file-by-file basis, unlike PCs. You can, if you like, override this by using the "always open with" option; see the "How do I set a default app" link in my sig.
-new files made by TextWrangler have the ".txt" extensions by default?
I don't believe so, but I'm sure that, if you send BareBones Software (the company) some feedback, they'll make this a preferences option in the future.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top