Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: CD command  (Read 10270 times)

0 Members and 1 Guest are viewing this topic.

reinaker

  • Guest
CD command
« on: May 19, 2007, 07:47:28 AM »
I am using the MS version XP, how do I return to a previous directory?

Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #1 on: May 19, 2007, 08:35:24 AM »
Welcome to ComputerHope, Reinaker.

I don't quite understand your queston. By returning to the previous directory, do you mean this:

CD = C:\windows\system32\
and change it to
C:\windows\

Is that what you mean?

contrex

  • Guest
Re: CD command
« Reply #2 on: May 19, 2007, 09:07:37 AM »
CD command syntax:

CD (alone) displays current directory

CD Drive: displays current directory on Drive:

CD directory changes to that directory

CD /D (directory) changes to that directory and changes drive to drive letter D

CD.. change to parent directory

That's it. No change to "previous directory".








Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #3 on: May 19, 2007, 09:10:40 AM »
You could adapt this code:

Code: [Select]
echo. %cd:~10,0%
« Last Edit: May 19, 2007, 09:20:48 AM by Carbon Dudeoxide »

contrex

  • Guest
Re: CD command
« Reply #4 on: May 19, 2007, 09:15:52 AM »
What's that meant to do?

Why the period after the echo?

Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #5 on: May 19, 2007, 09:19:48 AM »
type that in command prompt and press enter.
I have a habit of putting periods after 'echo'. Still works the same as 'echo '

contrex

  • Guest
Re: CD command
« Reply #6 on: May 19, 2007, 09:26:17 AM »
Code: [Select]
C:\>echo %cd:~20,0%
ECHO is on.

ie %cd~20,0% expands to... nothing.

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: CD command
« Reply #7 on: May 19, 2007, 09:26:50 AM »
What's that meant to do?

Why the period after the echo?


echo.      prints a blank line to the screen.

What it would do in his example, ... I really don't know.  I'd have to try it and see.
Maybe it is just a typo.

.



Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #8 on: May 19, 2007, 09:29:28 AM »
echo hello
works just the same as
echo.hello
Maybe it just works on XP or something, i dunno.

I just realised reinaker is not a member anymore. Wonder what happened.....

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: CD command
« Reply #9 on: May 19, 2007, 09:29:49 AM »
I am using the MS version XP, how do I return to a previous directory?

By any chance,  is this a repetitive thing?    In that you don't want to have to type out the whole path each time you wish to return to a certain directory, and whatever you are doing necessitates a lot of dir changing?

If so,  there is a way to get around that.

Check out:
http://www.computerhope.com/doskeyhl.htm

.



contrex

  • Guest
Re: CD command
« Reply #10 on: May 19, 2007, 09:31:25 AM »

echo.      prints a blank line to the screen.


Yes I did know that.  ::)



contrex

  • Guest
Re: CD command
« Reply #11 on: May 19, 2007, 09:32:45 AM »
so, dudeoxide, what's with this echo %cd:~20,0% thing? What does it do?

Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #12 on: May 19, 2007, 09:34:36 AM »
example:
echo %cd%  --> c:\documents and settings\user
echo %cd:~20,0% --> C:\documents and set

does that explain it? Basically gets rid of 20 letters at the end of the command...

contrex

  • Guest
Re: CD command
« Reply #13 on: May 19, 2007, 09:36:17 AM »
Quote
Basically gets rid of 20 letters at the end of the command...

I knew it did that. I do understand about string slicing. I meant what is the purpose of it. As in, what has it got to do with the question the guy asked.

(Sorry, am I being dumb here?)

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: CD command
« Reply #14 on: May 19, 2007, 09:36:59 AM »

echo.      prints a blank line to the screen.


Yes I did know that.  ::)





and yet you asked anyway?        .... odd.

.



Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #15 on: May 19, 2007, 09:38:24 AM »
he can use that to cd to his previous location.

contrex

  • Guest
Re: CD command
« Reply #16 on: May 19, 2007, 09:41:14 AM »

echo.      prints a blank line to the screen.


Yes I did know that.  ::)





and yet you asked anyway?        .... odd.



Maybe English is not your first language? I meant, "What is the reason why you have put a period after the echo command?", not "What does a period do after an echo command?"


Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #17 on: May 19, 2007, 09:43:42 AM »
Lol, what does it matter.
I find it easier for me to use 'echo. text' than 'echo  text'
You dont have to use the period for %cd:~20,0% but i did coz i could......

contrex

  • Guest
Re: CD command
« Reply #18 on: May 19, 2007, 09:46:37 AM »
he can use that to cd to his previous location.

Oh right. So I'm in D:\My Folders\*censored*\Mom don't look in here\Babes\Redheads and I

type CD d:\

So now I'm in d:\

I type your command and it cuts the last 20 characters off the directory name, which is actually 3 characters long, so I end up with an empty string, which ECHO interprets as a request to show ECHO status, so it says "ECHO is on", and that gets me back to my previous folder? Is that how it works?

That's a real clever DOS tip, dudeoxide! i would nevah have thunk of that all on my lonesome!


Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: CD command
« Reply #19 on: May 19, 2007, 10:03:05 AM »
well then you change 20 to a number that suits you.

contrex

  • Guest
Re: CD command
« Reply #20 on: May 19, 2007, 10:07:49 AM »
It's only useful if "where you were before" is  a parent folder of where you are now. typing cd.. (enter) and then repeatedly recalling it with the up arrow would do the same thing.

GuruGary



    Adviser
    Re: CD command
    « Reply #21 on: May 19, 2007, 02:28:51 PM »
    Reinaker: You can use PUSHD and POPD.

    For example, if you start off in
    Contrex's directory of
    D:\My Folders\*censored*\Mom
    And you want to go to the directory D:\Foo, you could use the command
    Code: [Select]
    pushd \FooThen to get back to the previous directory do
    Code: [Select]
    popdOr if you wanted to go to C:\Documents and Settings you could use the command
    Code: [Select]
    pushd "C:\Documents and Settings"Then to get back to the previous directory do
    Code: [Select]
    popd
    Another tip ... if you are writing a batch file that changes directories and it ends up leaving you in a directory used by the batch file instead of the original, you can use the SETLOCAL command.  Example:
    Code: [Select]
    @echo off
    setlocal
    cd \Temp
    ren *.new *.old
    In this example the batch file would leave you in whatever directory you started in.  Without the SETLOCAL command, the batch file would leave you in \Temp.