How to specify the current working directory in a batch file

I want to change the command:

copy "D:\Folder\File.txt" "C:\Folder\File.txt"

to:

copy "%current path%\File.txt" "C:\Folder\File.txt"

Is there a way to type input?

+4
source share
2 answers
copy "%cd%\some.file" "c:\there\some.file"

or

copy "%~dp0some.file" "c:\there\some.file"

they are different. %cd%is the current executable directory, and %~dp0is the bat file if the SHIFT command is not called. Also %~dp0can not be used from the command line, since there is no script.

+2
source

Try copy ".\File.txt" "C:\Folder\File.txt"

+1
source

Source: https://habr.com/ru/post/1535183/


All Articles