4

I'm trying to setup a work environment following this tutorial, but am hitting an error. The tutorial says to use

touch index.html

and since I am on a windows machine, I'm trying to use

NUL > index.html

but am getting the response: Access is denied. I've tried running the Command Prompt as an administrator but still get the same response. How do I get around this using the command line?


Edit:

It gave me the Access is denied response but still created the files.

phuclv
  • 37,963
  • 15
  • 156
  • 475
John Snow
  • 1,898
  • 2
  • 27
  • 48
  • 1
    Possible duplicate of [How to create empty text file from a batch file?](http://stackoverflow.com/questions/210201/how-to-create-empty-text-file-from-a-batch-file) – Mathias R. Jessen Apr 08 '17 at 16:25
  • I faced the same problem and git bash is a good help to go step by step with the bash commands. For that you need to install git. – Eftekhari Apr 08 '17 at 22:52

2 Answers2

3

touch is a Linux command, hence you have to see the Windows equivalent to it.

you have to type nul > filename.txt for creating the command. Sometimes this gives the "access denied" status report which I think due to the file settings. So you can try

echo. > filename.txt

Btw you don't need to write type in front of it... this must be told by the author to you to type (typing -gerund form of type) it

phuclv
  • 37,963
  • 15
  • 156
  • 475
1

I got the same "access denied" error because I tried to use "type nul" on a folder instead of a file. Comming from linux batch where touch can be used on a folder or a file, I mistakenly thought it could be done.

For touching files in windows command prompt:

type nul >> some_file_no_quotes_around_it.txt

For touching folders in windows command prompt:

IF NOT EXIST "./some_quoted_folder" mkdir "./some_quoted_folder"
KANJICODER
  • 3,611
  • 30
  • 17