54D
54D

Reputation: 219

How do I find current directory for my Batch file?

I am currently working on a batch file (let's call it temp.bat). I am trying to move the batch file to my desktop, but I can't find my batch file location / directory. I am asking if there is an extension or something that can use to automatically identify the directory, instead of entering it every time. In other words, I can still move the file to another place even in another directory. Example:

temp.bat is currently on my Downloads file. I use the move command to move the file to Desktop. Now temp.bat is currently on my Documents file. I try to use the same command to move the file to Desktop.

Is there any parameter extensions for it?

This is what I have now:

@echo off
move /y [The directory of temp.bat] C:\Users\69Swag\Desktop

All answers appreciated! Thanks :)

Upvotes: 0

Views: 113

Answers (1)

user1261104
user1261104

Reputation: 325

You don't need the current directory to move a file.

move temp.bat C:\Users\69Swag\Desktop

If you still want the current directory, use this:

echo %cd%

Upvotes: 1

Related Questions