How to go to this directory???
Moderator: DosItHelp
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
How to go to this directory???
Hi,
for example I want to go to this directory:
D:\my pic\new
I can use this:
D:
cd "my pic"
cd new
I want go to this directory just by one command line. What should I do?
or
for example in dos I have:
%dir%=d:\my pic\new
How to go to the directory in %dir%?
for example I want to go to this directory:
D:\my pic\new
I can use this:
D:
cd "my pic"
cd new
I want go to this directory just by one command line. What should I do?
or
for example in dos I have:
%dir%=d:\my pic\new
How to go to the directory in %dir%?
Re: How to go to this directory???
Read cd/?
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: How to go to this directory???
ok. thank u
my first question answered. but my secont question not answered yet.
please guide me
new question:
for example my batch file in this directory:
d:\new folder
I run the batch file and at last now in batch file we are in this directory:
f:\
How to back to first directory in dos(d:\new folder)?
How to find the directory that runing batch file is in it and how to go to this directory?
my first question answered. but my secont question not answered yet.
please guide me
new question:
for example my batch file in this directory:
d:\new folder
I run the batch file and at last now in batch file we are in this directory:
f:\
How to back to first directory in dos(d:\new folder)?
How to find the directory that runing batch file is in it and how to go to this directory?
Re: How to go to this directory???
There are a lot of possibilities. Try PUSHD and POPD.
Example:
Otherwise the drive and path of your batch file you can find in %~dp0 so you could use
if you want to change the working directory to the folder your batch file is saved in.
Regards
aGerman
Example:
Code: Select all
@echo off &setlocal
echo %cd%
cd /d "D:\my pic\new"
echo %cd%
pushd "F:\"
echo %cd%
popd
echo %cd%
pause
Otherwise the drive and path of your batch file you can find in %~dp0 so you could use
Code: Select all
cd /d "%~dp0"
if you want to change the working directory to the folder your batch file is saved in.
Regards
aGerman
Re: How to go to this directory???
Mohammad_Dos wrote:How to find the directory that runing batch file is in it and how to go to this directory?
1st way
Code: Select all
set "home=%cd%"
...
...
chdir /d %home%
2nd way
Code: Select all
chdir /d %~dp0
3rd way
Code: Select all
pushd f:\
...
...
popd
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: How to go to this directory???
thank u very much !k and aGerman
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: How to go to this directory???
and now I have a new question.
How to copy some files to directory that the batch file is in it?
for example I runed a batch file and want copy all files in "D:\new Folder\Pic" to batch file directory
How to copy some files to directory that the batch file is in it?
for example I runed a batch file and want copy all files in "D:\new Folder\Pic" to batch file directory
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: How to go to this directory???
thank u very very much