I am writing a code to copy a few files for backup which is sort of everyday work for which I use CD using DOS to set the directory.
How do I create a DOS command line to auto detect the path were I have placed it (the location of code) rather than it automatically getting set to C:\Users\ME.
Sort of like:
CD C:\Users\ME\Ryan\Folder1
COPY *.txt C:\Users\ME\Ryan
CD C:\Users\ME\Ryan\Folder2
COPY *.xls C:\Users\ME\Ryan
{Code placed in C:\Users\ME\Ryan}
CD C:\Users\ME\Ethan\Folder1
COPY *.txt C:\Users\ME\Ethan
COPY *.xls C:\Users\ME\Ethan
{Code placed in C:\Users\ME\Ethan}
So Folder1 & Folder2 remains the same always.
So how can I make dos auto-update the path in the code (C:\Users\ME\Ryan, C:\Users\ME\Ethan) by checking where it exists.
Please help any clues would be appreciable. Thanks!!
How do I make any executable dos code auto-detect a path?
Moderator: DosItHelp
-
- Posts: 1
- Joined: 25 Dec 2011 12:47
Re: How do I make any executable dos code auto-detect a path
The path (with a trailing backspace) of the batch file can be found in
The current working directory (without trailing backspace) can be found in
Regards
aGerman
Code: Select all
%~dp0
The current working directory (without trailing backspace) can be found in
Code: Select all
%cd%
Regards
aGerman