Link to home
Start Free TrialLog in
Avatar of rfreeman1960
rfreeman1960

asked on

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

Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

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
ASKER CERTIFIED SOLUTION
Avatar of t0t0
t0t0
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rfreeman1960
rfreeman1960

ASKER

Worked great!
Thank you for the points and for posting an interesting question.