Computing.Net > Forums > Programming > Batch file entering text

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file entering text

Reply to Message Icon

Name: gunslingor
Date: March 18, 2009 at 10:08:52 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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%



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: March 18, 2009 at 10:40:31 Pacific
Reply:

echo "Is this going in?" >> %CD%\Data\%computername%\%file_name%

--
Holla.


0

Response Number 2
Name: gunslingor
Date: March 18, 2009 at 11:19:50 Pacific
Reply:

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?


0

Response Number 3
Name: gunslingor
Date: March 18, 2009 at 11:29:30 Pacific
Reply:

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 >>?


0

Response Number 4
Name: gunslingor
Date: March 18, 2009 at 11:37:30 Pacific
Reply:

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!


0

Response Number 5
Name: Holla
Date: March 22, 2009 at 11:59:35 Pacific
Reply:

If your %CD% contains spaces, use
echo "Is this going in?" >> "%CD%\Data\%computername%\%file_name%"

--
Holla.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

visual voxpro .exe does n... Write the following MS-DO...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file entering text

Batch file adding text to file also www.computing.net/answers/programming/batch-file-adding-text-to-file-also/16756.html

Batch file pasting text www.computing.net/answers/programming/batch-file-pasting-text/18760.html

Batch file for text replacement www.computing.net/answers/programming/batch-file-for-text-replacement/12883.html