|
Answer» How can I get the path of CURRENT directory?
I want to copy some files from current directory to c:\windows\system32
Now my current directory is C:\Documents and Settings\Shajahan\Desktop\fatal It will change any time So I want to pick the current directory
pls help me soontype this at the prompt and you'll know the answer
echo %CD%i know that
i want to RUN from windos so where i put the batch file i want the path of that directory
maybe from desktop maybe from mydocumentSo, you to copy a file from whatever your current directory is to C:\Windows\system32? Code: [Select]copy filename.ext C:\Windows\system32For multiple files, you can use a wildcard, like *.dll
Or from a batch file, you can do: Code: [Select]copy %1 C:\Windows\system32and put the batch file somewhere in your path, and call the batch file with the filename you want to copy from your current directory.
Is that what you are looking for?shajahan, the "current directory" in DOS and in NT is the directory you are logged into, that is, the directory WHOSE path forms the prompt. That is the CONTENTS of the %CD% variable. In a batch file, the variable %~dp0 is the folder that the batch file is located in.
here is the batch file F:\test\cdir\show.bat
Code: [Select]@echo off echo the current directory is %CD% echo this batch file is in directory: %~dp0
Code: [Select]F:\test\cdir>show.bat the current directory is F:\test\cdir this batch file is in directory: F:\test\cdir\ F:\test\cdir> F:\test\cdir>cd..
F:\test>f:\test\cdir\show.bat the current directory is F:\test this batch file is in directory: f:\test\cdir\ F:\test>c:
C:\>f:\test\cdir\show.bat the current directory is C:\ this batch file is in directory: f:\test\cdir\ C:\>e:
E:\>f:\test\cdir\show.bat the current directory is E:\ this batch file is in directory: f:\test\cdir\ E:\>
|