Syed Galib
Syed Galib

Reputation: 88

How to mention current working directory in 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 any way to type like this?

Upvotes: 4

Views: 1484

Answers (2)

Mukul Jain
Mukul Jain

Reputation: 21

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

Upvotes: 1

npocmaka
npocmaka

Reputation: 57252

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 %~dp0 is where the bat file is in case the SHIFT command is not called.Also %~dp0 cannot be used from the command line as there is no script file.

Upvotes: 3

Related Questions