How to add a CRLF

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Docfxit
Posts: 132
Joined: 12 Nov 2015 12:42

How to add a CRLF

#1 Post by Docfxit » 16 Oct 2022 12:58

This bat file checks to see if files exist. It lists the files that are not found all on one line. I'd like to know how to change it to list each file on a line of it's own. This is what the output looks like:
VNCInstallBat.jpg
VNCInstallBat.jpg (33.7 KiB) Viewed 2537 times
This is what the bat file looks like now:

Code: Select all

(set file=)
if not exist "VNC UltraVNC_1_2_22_X64_Setup.exe" (
set file=VNC UltraVNC_1_2_22_X64_Setup.exe)
if not exist VNCsaveinf.inf (
set file=%file% VNCsaveinf.inf)
if not exist VNCsetup.reg (
set file=%file% VNCsetup.reg)
if not exist SecureVNCPlugin64.dsm (
set file=%file% SecureVNCPlugin64.dsm)
if not exist rc4.key (
set file=%file% rc4.key)
if defined file (
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
Echo.
echo    旼컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴커
echo    ?                                
echo    ?  The files "%file%" do not exist in this directory
echo    ?  Move the above files into %CD% 
echo    ?                                
echo    ?                                
echo    ?                                
echo    ?  Press any key to close this window                              
echo    ?                                
echo    읕컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴켸
Pause > Nul
 )

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to add a CRLF

#2 Post by aGerman » 16 Oct 2022 14:52

Try something about like that.

Code: Select all

@echo off
(set lf=^
%= creates a line feed, do not alter =%
)

setlocal EnableDelayedExpansion
set "file="
if not exist "foo.exe" set "file=!file!!lf!   ?    foo.exe"
if not exist "bar.txt" set "file=!file!!lf!   ?    bar.txt"
if defined file  (
  echo    ?  The files ...!file!
  echo    ?  ... do not exist in this directory.
)
endlocal

pause

Docfxit
Posts: 132
Joined: 12 Nov 2015 12:42

Re: How to add a CRLF

#3 Post by Docfxit » 16 Oct 2022 15:12

That looks super great.

Thank you very much. :lol: :lol: :lol: :lol:

Post Reply