Solved VBScript File creation problem

December 26, 2013 at 14:45:58
Specs: Windows XP
Hey guys, I just want to ask if a VBScript can create multiple files in one directory with names based off of an InputBox output.
Example:
inputbox("Write Something")

And then if someone typed 'Cow' then it would create a file Named 'Cow.txt' please answer.
thanks


See More: VBScript File creation problem

Report •


#1
December 26, 2013 at 20:27:19
Yes. Batch could also handle this, no problem. As long as there are no duplicate filenames generated.

Report •

#2
December 27, 2013 at 14:11:00
How exactly can this be achieved?

Report •

#3
December 27, 2013 at 19:36:55
✔ Best Answer
Here's Vbs, minimized. If you want embellishment, you'll mostly have to do your own development - download "script56.chm" if you want a help file.
'======= begin vbscript
set fso=createobject("scripting.filesystemobject")
a=inputbox("Write something:","File Creation exercise")
a=a&".txt"
if fso.fileexists(a) then
msgbox(a&" already exists, safety-abort")
else
fso.createtextfile(a,False)
end if
'========
and here's batch:
::====== begin batchscript
@echo off
set a=
set /p a=Write something:
if not defined a goto :eof
set a=%a%.txt
if exist %a% (
echo %a% already exists, bye!
) else (
set /p =<nul>%a%
)
::====== end batch

message edited by nbrane


Report •

Related Solutions

#4
December 27, 2013 at 20:13:13
Thanks for helping me.

Report •


Ask Question