1.

Solve : adding lines to a output text file?

Answer»

I WANT to add line1 line2 line3 hard coded in the batch file to a text file. I need crlf after each line.
If I press enter it doesn't work so I need to add a crlf not enter in the batch program.

for /F "delims==" %%A in (c:\nameftp\list.txt) do
echo push/pull:push remotedirectoryname:ABC\EntryB\
filename:%%A
remoteserverIP:123.123.123.5
userID:abcid
passwd:password
emailaddr:[emailprotected]
newfilename: >> c:\ABCftp\%%A.xfr
This is how, in a batch file you add lines to a text file. Each line has a cr/lf at the end.

echo This is a line of text >> already_exists.txt
echo This is another line of text >> already_exists.txt

I am not sure what that code you posted is supposed to do? As written, it will just throw up a lot of error messages.




The prog copies the files in the list.txt the next list takes each file and add it to a line in the text file and names the file the file name plus a new ext. For each file in the dir a text file is CREATED with the file name in the txt and ren to the file name. Each line has to be on a new line.

dir/B/O:n > c:\abcftp\list.txt
for /F "delims==" %%A in (c:\abcftp\list.txt) do
echo push/pull:push >> c:\abcftp\%%A.xfr
echo remotedirectoryname:abc\EntryB\ >> c:\abcftp\%%A.xfr
echo filename:%%A >> c:\abcftp\%%A.xfr
echo remoteserverIP:123.123.12.43
echo userID:abcftpid >> c:\abcftp\%%A.xfr
echo passwd:abctflhd >> c:\abcftp\%%A.xfr
echo emailaddr:[emailprotected] >> c:\abcftp\%%A.xfr
echo newfilename: >> c:\delphiftp\%%A.xfr

thanks for the helpQuote

for /F "delims==" %%A in (c:\abcftp\list.txt) do

What do you expect this line to do?
I want to be able to start with push/pull:push and add each line to a text file on a separate line. The var %%A is the file name and is also plugged into the text where it says filename=%%A. The script works but the text to the file is on one line.

thanks muchThis line does nothing

for /F "delims==" %%A in (c:\abcftp\list.txt) do
for /F "delims==" %%A in (c:\nameftp\list.txt) do echo push/pull:push remotedirectoryname:ABC\EntryB\ filename:%%A remoteserverIP:123.123.123.5 userID:abcid passwd:password emailaddr:[emailprotected] newfilename: >> c:\ABCftp\%%A.xfr

This works but it put everything on one line in the text file. I want it on separate lines in the text file. How do you add crlf or how do you write it to add each group on a line.
example

push/pull:push
remotedirectoryname:ABC\Entry\Filename:%%A
remoteserverip:123.123.123.5
the FOR command has 2 forms

1. SINGLE line

for [...] %%V in (something) do [command]

2. Multiple line - NOTE parentheses!

for [...] %%V in (something) do (
[command]
[command]
[command]
[command]
)


So...

dir /B /O:n > c:\abcftp\list.txt
for /F "delims==" %%A in (c:\abcftp\list.txt) do (
echo push/pull:push > c:\abcftp\%%A.xfr
echo remotedirectoryname:abc\EntryB\ >> c:\abcftp\%%A.xfr
echo filename:%%A >> c:\abcftp\%%A.xfr
echo remoteserverIP:123.123.12.43 >> c:\abcftp\%%A.xfr
echo userID:abcftpid >> c:\abcftp\%%A.xfr
echo passwd:abctflhd >> c:\abcftp\%%A.xfr
echo emailaddr:[emailprotected] >> c:\abcftp\%%A.xfr
echo newfilename: >> c:\abcftp\%%A.xfr
)


thank you it works


Discussion

No Comment Found