Need to write a .bat file that when it runs, displays my current directory

Posted on 2012-09-12
Last Modified: 2012-09-12
I am new to .bat files. I just need to make one that will run and display the directory i'm in. Can anyone help me out?

@echo off
echo Your current directory is
dir C:/windows

Open in new window

was my starting point
Question by:Mark_Co
    LVL 82

    Assisted Solution

    @echo %cd%

    Open in new window

    LVL 51

    Assisted Solution

    by:Bill Prew
    Building off what you had:

    @echo off
    echo Your current directory is:
    echo %CD%

    Open in new window

    LVL 82

    Accepted Solution

    Wait; do you mean "show the current directory", or "show the content of the current directory"? From your example, it's not quite clear; some examples:
    @echo off
    echo Your current directory is %cd%
    echo The content of the current directory:
    The content of the folder this script is in:
    dir "%~dp0"
    The content of the Windows folder:
    dir "%Systemroot%"

    Open in new window


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    The way I use Experts Exchange to assist me in analyzing and diagnosing a problem is I first enter a Verbose Question at Experts Exchange like: Office 2007 will hang when opening and saving files I then launch WordPad (any text editor will do) an…
    This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now