Batch file entering text

March 18, 2009 at 10:08:52
Specs: Windows XP
My batch file currently creates a folder with the name of the computer, then creates a txt file with the name of the computer in the aforementioned folder. Now what I need to do is get the text "Name of Computer is: %computername% " into that file. I have looked at 'type' and 'copy' but both seem to only work for appending files. How do I append text to the file. As an example (this isn't really the case but demonstrates the same problem with a different application), say I want the user to enter the text; how? Here is the code I am trying to get working:
type  "Is this going in?" >> %CD%\Data\%computername%\%file_name%


See More: Batch file entering text

Report •


#1
March 18, 2009 at 10:40:31
echo "Is this going in?" >> %CD%\Data\%computername%\%file_name%

--
Holla.


Report •

#2
March 18, 2009 at 11:19:50
it Doesn't seem to be working. Could it be that the path is to large? any other ideas?

Also, a few questions
1. When should you use quotes?
(e.g. Call "setup.bat" or w/o quotes?)
(e.g. "@copy nul Data\%computername%\%file_name%" or w/o quotes?)
(e.g. echo "hello!" or "echo hello" or echo hello?)
2. When do you use '>' or '>>'? whats the difference?
3. whats the difference between %1 and %%1?


Report •

#3
March 18, 2009 at 11:29:30
This works correctly:
echo "Is this going in?" > Data\%computername%\%file_name%

Any idea why it doesn't work with the additional %CD%\ master directory? Logically I think it should.
Also, whats the difference between > and >>?


Report •

Related Solutions

#4
March 18, 2009 at 11:37:30
LoL, Okay. The method we have been talking about overwrites the text in the file I need to do this:
@echo COMPUTER NAME: %computername% > Data\%computername%\%file_name%
@echo SCAN DATE: %fdate% > Data\%computername%\%file_name%
@echo SCAN TIME: %ftime% > Data\%computername%\%file_name%

but it overwrites the data on each echo. Hmm, wonder if thats where the >> comes in? let me try....... HAHA! I solved my own questions/problems just by talking to myself on this thing! yipi!


Report •

#5
March 22, 2009 at 11:59:35
If your %CD% contains spaces, use
echo "Is this going in?" >> "%CD%\Data\%computername%\%file_name%"

--
Holla.


Report •


Ask Question