batch-filedirectorycreation

Create a txt file using batch file in a specific folder


I am trying to create a batch file which will create a text file in a specific folder. I am able to create a text file on my desktop, but I need to create a file in a specific file path.

For example in D:/Testing folder I wants to create a user defined text file.

@echo off

echo .>> dblank.txt

I am using the above code to create a .txt file on my desktop.

I know this is a simple question but I searched google and have not found any good solution that could helpful to me.


Solution

  • You have it almost done. Just explicitly say where to create the file

    @echo off
      echo.>"d:\testing\dblank.txt"
    

    This creates a file containing a blank line (CR + LF = 2 bytes).

    If you want the file empty (0 bytes)

    @echo off
      break>"d:\testing\dblank.txt"