create txt file from cmd

  • Thread starter Thread starter hudan
  • Start date Start date
H

hudan

Hi,
I just try to find command from windows xp cmd which will create txt
file and save on local drive.
Similar like touch command in unix.

Please help.

Thanks
Dan
 
Hi Dan,

One way to create a text file in a Windows cmd script is

ECHO "Write this to a file" > "C:\Folder\Filename.txt"

The "touch" command I know doesn't create files, it changes the
timestamps on files that already exist. There are any number of Windows
utilities that do this job; some of them are called "touch.exe".

If you want a faithful Unix "touch", you'll find Windows ports of GNU
utilities at http://unxutils.sourceforge.net/ .
 
This works for me

Function CreateTxt(FileName As String)
Dim hFile As Integer
hFile = FreeFile

Open FileName For Append As #hFile

'Print #hFile, ""

Close #hFile
End Function

As you can see, by simply commenting out the Print line which would normally
add content to the file, your file is created empty. The FileName variable
include the full path such as "c:\text.txt"

Daniel
 
Back
Top