Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify the current directory in Windows Shell?

I have the following BAT file which is intended to archive the specified folder, protect it by a password and copy the archive file to my local Dropbox folder.

    "C:\Program Files\7-Zip\7z.exe" a -mx9 archive.7z "G:\This is a test\directory\with subdirectories\" -psecret -mhe=on

    xcopy "G:\This is a test\directory\with subdirectories\archive.7z" "G:\My Documents\My Dropbox\" /c /d /s /e /k /y

I use 7-Zip for archiving.

Is it possible to alter the script in such a way that I can put it in any folder I choose and it does the same - archive the current folder, protect it by a password and copy the archive file to my local Dropbox folder?

Simply said, what is the command for "archive the current directory and any sub-directories"?

like image 367
quanto Avatar asked Jul 12 '11 13:07

quanto


People also ask

How do I get the current directory in Windows?

MS-DOS and Windows command line current directory To list the files in the current directory use the dir command, and if you want to change the current directory, use the cd command. You can use the chdir command by itself to print the current directory in MS-DOS and the Windows command line.

How do I get the current directory in terminal?

To see them in the terminal, you use the "ls" command, which is used to list files and directories. So, when I type "ls" and press "Enter" we see the same folders that we do in the Finder window.

How do I change a directory from C to D in CMD?

For instance, if you wanted to change the drive from C: to D:, you should type: d: … and then press Enter on your keyboard. To change the drive and the directory at the same time, use the cd command, followed by the /d switch.


1 Answers

%CD% is your current directory. Try echo %CD% in a dos prompt to try it out.

like image 153
Ardesco Avatar answered Oct 20 '22 22:10

Ardesco