Avatar of AL_XResearch
AL_XResearchFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Windows batch files do not show consistently in Notepad

I have several files which are Batch or XML files and on some Windows systems they show correctly (i.e. readable) and some others they show with all the lines run together (i.e. unreadable).

I have a suspicion this is because the line break characters are being interpreted differently by the different windows installs.

Has anyone had this themselves and can point me in the correct location to correct ?
Windows BatchMicrosoft DOSXMLProgramming

Avatar of undefined
Last Comment
AL_XResearch
SOLUTION
Avatar of Bill Prew
Bill Prew

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

I am afraid I can't upload the files as they are propriety information.

I use ConText programmers editor (an excellent editor - see) and that honours the line-ends but Notepad does not.
Avatar of Bill Prew
Bill Prew

Okay, understand.

Yes, many text editors are smart enough to treat either a single <CR> or a single <LF> as a line termination indicator if they don't see the standard <CR><LF> pair present.

So I guess I'm still where I mentioned earlier.  I expect that the files on those Windows machines are different than on the other Windows machine, with regard to the EOL characters.  If ConText has a HEX view mode that shows all characters including the EOL ones then you could see that.

And if so, then the question becomes what was done differently in placing those files on the different Windows machines, that changed the EOL sequence.  Certainly this is common when FTP from a Unix box is involved, but you haven't mentioned that so I won't assume.

Notepad is not as 'smart' as most text editors, it needs the <CR><LF> pair to behave properly I believe.

~bp
SOLUTION
Avatar of dbrunton
dbrunton
Flag of New Zealand image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Bill: This is exactly what I was thinking.

The files are installed / created by third party software installation and quite possibly were originally created or stored on a UNIX box.

I had the same thought about using a hex editor to check the end-of-line terminators. Do you know a good open-source one that can be used commercially ?
Avatar of Bill Prew
Bill Prew

It's not fancy, but I have used some of their other tools so picked this up at one point as well.

https://www.funduc.com/fshexedit.htm

There are a number of free options out there, if you want to explore further take a look at this wiki page:

https://en.wikipedia.org/wiki/Comparison_of_hex_editors

~bp
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

I have used Notepad++ and set the 'View | Show Symbol | Show End Of Line' and it confirms that the Batch file must have either been created or FTPed to a Unix system as the end of line char is just a 'LF'.

That still does not explain why sometimes Notepad shows the lines correctly and sometimes with all the lines run together. Maybe when settings in the application change it modifies the batch file but since it is now on a Windows box it uses CR+LF  ?
SOLUTION
Avatar of dbrunton
dbrunton
Flag of New Zealand image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Have you tried running the unix2dos tool I suggested and linked to above?
No I haven't used that tool. I don't want to change the file (or risk changing the reliant software's functionality) - I just wanted to explain why sometimes the lines are run all-together and sometimes appear fine. The suggestion I have given is the only thing I can think of.
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

In actual fact, if I wanted to change the EOL markers, Notepad++ will do this easily from a menu selection.
Avatar of Bill Prew
Bill Prew

That still does not explain why sometimes Notepad shows the lines correctly and sometimes with all the lines run together.
Have you also looked at the file with Notepad++ on a system where the line wrapping is handled properly, and if so do you see <CR><LF> as the end of line sequence there?  I have to think you will, and if that is the case then something different is happening in the way the files are created or moved to the different Windows machines.  Hard to guess what that could be without more info, but if you want to detail the creation and distribution of the file that would be a start.

~bp
ASKER CERTIFIED SOLUTION
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of AL_XResearch
AL_XResearch
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

It turned out that it was not a file difference but a mistake on the user's part who identified the issue. However it was useful to know that the EOL markers cannot be changed in Windows by Notepad++ can change the EOL markers in a file.
Programming
Programming

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo