Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
What I would like to do is be able to take a variable with spaces in it and make a file with the name of the variable, as such:
set /p address=Enter the address:
Echo. >> %address%.txtAll it does is copy the first word of
%address% to the filename. I was wondering if you could take out the spaces within the variable, and then maybe do as the following:Echo. >> "%word1% %word2%.txt"
I would also like this in batch only if possible.
crappy OEM comptuers...

EDIT: Got it to work.
echo. >> "%address%".txtThen if you want it in a different directory, first cd to the directory of the folder "%address%".txt is located.
copy "%address%".txt "your\new\location"crappy OEM comptuers...

This can be done using Visual Basic scripting:
1.Create a batch file with the following line:
wscript string.vbs2.Create a new txt file:
string.txt3.Rename string.txt to string.vbs
4.Enter the following lines in the vbs file:
Dim x
Dim s
x=inputbox("enter address:")
s = replace(x," ","")
x=s+".txt"
Msgbox(x)5. Execute the batch file:
x will be the filename adress.txtIf you enter 'my new documents' when prompted for address:
x will be mynewdocuments.txt

Well I originally thought I couldn't get spaces within a filename, so then I wanted to try getting rid of the spaces.
Also, Visual Basic is a lil confusing to me XPcrappy OEM comptuers...

![]() |
![]() |
![]() |

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