[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-09-12
3
Medium Priority
?
510 Views
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
pause

Open in new window


was my starting point
0
Comment
Question by:Mark_Co
  • 2
3 Comments
 
LVL 85

Assisted Solution

by:oBdA
oBdA earned 1400 total points
ID: 38392192
@echo %cd%

Open in new window

0
 
LVL 59

Assisted Solution

by:Bill Prew
Bill Prew earned 600 total points
ID: 38392203
Building off what you had:

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

Open in new window

~bp
0
 
LVL 85

Accepted Solution

by:
oBdA earned 1400 total points
ID: 38392224
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:
dir
The content of the folder this script is in:
dir "%~dp0"
The content of the Windows folder:
dir "%Systemroot%"
pause

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

834 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