How to echo a CRLF or Enter at the end of an Echo'd redirected command.

software:  MS's FTP.exe command line.
I am dynamically creating an FTP script from a batch file, so that each time it runs it creates a folder on the FTP host with the current date time in the format "yyyy-mm-dd at hhmmss"

rem another line in the script defines the string to an env var.
dt1 = <calculated data time string - all ready works>

rem Single line of script shown below.
echo dt1 >> c:\ftp.scr

The problem is that I need to add a carrage return line feed or enter characters to the end of the line, either in the echo or as part of dt1 as other lines are appended to the script both before and after this command.  How can this be done by using only the batch file.

@echo off
:: file = MakeNewFolderCurrentDateTime.bat
::
:: description = this batch file uses current date and time to create a file with a unique filename
 
::
:: Date         Author    Change/Update
:: 04-Jun-2005  AGButler  Original
::
 
:: set variables
set tdtd=none
set ttrn=none
 
 
:: get the date and time and then into single variable
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%i%%j%%k
 
for /F "tokens=2 delims=/ " %%i in ('date /t') do set mm=%%i
for /F "tokens=3 delims=/ " %%i in ('date /t') do set dd=%%i
for /F "tokens=4 delims=/ " %%i in ('date /t') do set yyyy=%%i
 
 
for /F "tokens=5-9 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set ttrn=%%i%%j%%k%%l%%m
 
for /F "tokens=5 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set h=%%i
for /F "tokens=6 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set m=%%i
for /F "tokens=7 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set s=%%i
for /F "tokens=9 delims=:. " %%i in ('echo.^| time ^| find "current" ') do set pm=%%i
 
set tufn=%tdtd% %ttrn%.txt
 
set date1=%yyyy%-%mm%-%dd%
set time1=%h%%m%%s%%pm%
 
 
rem type NUL>%date1% 
 
rem md %%date1%%
 
:: now create the file or Directory
 
set tufn=%tdtd%%ttrn%
 
:: Make Folder
:: md %date1%@%time1%
 
:: Make File
rem type NUL>%tufn%.txt
 
:EOF
 
 
@Echo off
cls
Echo Running Script to dynamically Create FTP Script file.
Echo:
Echo:
 
Echo Z,
Echo:
Echo cr.txt is "copy con cr.txt" <enter><ctrl-m><ctrl-z>enter from command prompt.
Echo:
echo:
echo ctrl-z yes to above.
Echo:
echo:
pause
 
echo lcd m:\FTP > c:\ftp.scr
echo open networkerweb.com >> c:\ftp.scr
echo userid >> c:\ftp.scr
echo password >> c:\ftp.scr
echo MKD %date1%@%time1% >> c:\ftp.scr
echo bye >> c:\ftp.scr
echo quit >> c:\ftp.scr
Echo:
Echo:
 
Rem Just to view the file below.
notepad c:\ftp.scr
pause
exit

Open in new window

rfreeman1960Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
Not sure what you are asking for here.  If you do an echo something>>whatever.txt it will create a file with

something <cr><lf>

if ou want a blank line in a file just use

echo. >>yourfile.txt

Some of your script with time/date could be simplified using %time% and %date% along with %time:~0,2% etc. to get first two chars etc. and %time::=% to strip all colons out etc. but if its working leave as is...

If you could clarify will look again later if someone hasn't solved inbetween

Steve
0
t0t0Commented:
To create a file comprising of just the carriage return and linefeed charcters, you could copy the console to a file named CRLF such as:

COPY CON CRLF

Then, press the carriage return key (or ENTER key) just once only. This will place the two characters into the newly created file named CRLF.

Finally, to close the file CRLF, press CTRL-Z followed immediately by the ENTER key (at which point you'll see tha familiar "1 file(s) copied." message ).

(You'll notice the file length of CRLF is just 2 bytes - as you would expect it to be)

To use the CRLF file, in your case, suppose you want to add a CR and LF character to your file, this can be done as follows:

echo dt1>>c:\ftp.scr
copy CRLF>>c:\ftp.scr


As dragon-it pointed out above, the follwing would also work in your case:

echo dt1>>c:\ftp.scr
echo.>>c:\ftp.scr

(notice the fullstop character after the echo statement).

On a final note.... if you have a hex file viewer, you'll notice in both instances redirecting the output into an empty file you get the follwing two characters:

0D 0A

(I use ztree for windows v1.60 for viewing files in hex mode)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rfreeman1960Author Commented:
Worked great!
0
t0t0Commented:
Thank you for the points and for posting an interesting question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.