Write current directory in a text file

1

In a batch program I have:

echo Date >c:\users\...\testecmd.txt

Writes the current date to a text file.

Assuming I do not know where the directory in which the self executable is, how do I get it to call the Current Directory instead of " c: \ users ... \ testcmd.txt "and write this same directory instead of Date p>

echo "c:\Diretorio\atual\" >c:\diretorio\atual\testecmd.txt
    
asked by anonymous 17.02.2016 / 04:15

1 answer

3

%CD% is the environment variable that contains the current directory. And if you want to access a file in the current directory, you can use . :

echo %CD% > .\testecmd.txt

The testecmd.txt file will be created in the current directory, and its contents will be the full name of the current command line directory.

    
17.02.2016 / 05:03