Go Back   TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What is the easiest way to convert unix/linux text files to DIS/Win text files?

Windows XP Support


Reply
 
Thread Tools Search this Thread
  #1  
Old 21-12-2007
Member
 
Join Date: Jan 2006
Posts: 115
What is the easiest way to convert unix/linux text files to DIS/Win text files?

It is known that the line endings/carriage returns in text files under Unix/linux usually differ from those under DOS/Windows XP. So lets say I got a text file with unix style line feeds. So what is going to be the easiest way to convert all line endings to Windows XP Style? Thanks for any information in advance.

Reply With Quote
  #2  
Old 21-12-2007
Member
 
Join Date: Jan 2006
Posts: 605
Re: What is the easiest way to convert unix/linux text files to DIS/Win text files?

You can try to get the Unix2Dos tool which is a tool to convert line breaks in a text file from Unix format (Line feed) to DOS format (carriage return + Line feed) and vice versa. Download it by searching it on the net.
Reply With Quote
  #3  
Old 21-12-2007
Member
 
Join Date: Nov 2005
Posts: 625
Re: What is the easiest way to convert unix/linux text files to DIS/Wintext files?

You can also get AutoIt which is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys).
Reply With Quote
  #4  
Old 21-12-2007
Member
 
Join Date: Dec 2004
Posts: 419
Re: What is the easiest way to convert unix/linux text files to DIS/Win text files?

There is an option in Unix to write text files with CRLF at the end of each line. Alternatively you could open the file with Word, then save it as a text file. You will be prompted to specify the EOL string, i.e. CRLF.
Reply With Quote
  #5  
Old 22-12-2007
Member
 
Join Date: Nov 2005
Posts: 403
Re: What is the easiest way to convert unix/linux text files to DIS/Win text files?

You can use the VBScript file on the desktop. Unix has one variation. Some Windows files (like Word docs) have another variation. The standard in Windows is to end the line with ASCII characters 13-10. (Carriage return - line feed). Just paste the below text to Notepad and save it as a .vbs file, you can just drop any file onto it and have it fixed. (Note that in some cases on XP you may need to adjust security to run a .vbs file.)

'---------------- start text of vbs file ------------

Dim fso, ts, s, arg, fil, fpath, s1
Set fso = CreateObject("Scripting.FileSystemObject")
arg = WScript.arguments.item(0)
Set ts = fso.OpenTextFile(arg, 1, False)
s = ts.ReadAll
ts.Close
Set ts = Nothing

s1 = Replace(s, vbCrLf, vbCr, 1, -1, 0)
s1 = Replace(s1, vbLf, vbCr, 1, -1, 0)
s1 = Replace(s1, vbCr, vbCrLf, 1, -1, 0)

Set ts = fso.CreateTextFile(arg, True)
ts.Write s1
ts.Close
Set ts = Nothing
Set fso = Nothing
MsgBox "All done", 64, "File fixed"

' -------- end vbs file ---------------

Another variation, if you want to save the edited text
to a different file, replace the line:

Set ts = fso.CreateTextFile(arg, True)

with:

Set ts = fso.CreateTextFile(arg & ".txt", True)
Reply With Quote
  #6  
Old 22-12-2007
Member
 
Join Date: Oct 2005
Posts: 449
There is another one called Dos2unix that includes utilities to convert text files with DOS or MAC line breaks to Unix line breaks and vice versa. It is an update of Benjamin Lin's implementations. Get it by searching on the web and install it in your pc.
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is the easiest way to convert unix/linux text files to DIS/Win text files?"
Thread Thread Starter Forum Replies Last Post
Convert MP3 to text with Speech to text in Word. Ashish Goenkar MS Office Support 1 04-02-2013 10:19 AM
How to convert image text into a text file Wadee Windows Software 5 02-12-2010 05:33 PM
How to read 2 text files and write it into one Juaquine Software Development 4 18-02-2010 05:05 PM
Vba import text files Naval Software Development 1 24-03-2009 11:35 PM
How to encrypt & decrypt text or files in Vb dot net? ArunJ Software Development 4 27-02-2009 08:01 PM


All times are GMT +5.5. The time now is 11:46 AM.