create txt file from cmd

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
 
J

John Nurick

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/ .
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top