Results 1 to 4 of 4

Thread: Retrieving the current directory in batch

  1. #1
    Join Date
    May 2009
    Posts
    543

    Retrieving the current directory in batch

    I wanted to make sure that the script is calling command or program at correct path so i want to search a file in the current directory from which the batch is running. So i need help from you all guys to retrieve the current directory name from a batch file. Please help.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Retrieving the current directory in batch

    Here's the code to get hold of the current directory:
    for /f %%i "delims=" in ('cd') do set cwd=%%i
    This is infact useful in manipulation of file and folder is done at valid destination when using relative path.The current dir is stored in the variable %CD%.Using the command ECHO %CD% will show you what it is.

  3. #3
    Join Date
    Feb 2009
    Posts
    240

    Re: Retrieving the current directory in batch

    The %CURRENTDIR% variable to store the current working directory, which can be used in batch commands. In case you want to only display current working directory, than use this command; Echo %CD%. You can also use Set CURRENTDIR=%CD% to save and store the current directory where a file is located.

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Retrieving the current directory in batch

    Thats is all i needed. Thanks a lot mate. I tried it and it worked for me. I often find myself in a directory where there's a file that I want to operate on. I appreciate your help. Thank you

Similar Threads

  1. Get latest updated file from your Current Working Directory
    By REDBULL in forum Software Development
    Replies: 4
    Last Post: 10-07-2010, 02:38 PM
  2. Batch script to delete directory
    By Logan 2 in forum Software Development
    Replies: 4
    Last Post: 01-04-2010, 12:31 PM
  3. Batch file to check directory
    By Trini Alvarado in forum Software Development
    Replies: 5
    Last Post: 01-04-2010, 11:00 AM
  4. How to make use of VB Script to get Current Directory?
    By BenTen in forum Software Development
    Replies: 2
    Last Post: 12-01-2009, 08:34 PM
  5. How to get current directory
    By Scott2580 in forum Software Development
    Replies: 3
    Last Post: 11-10-2008, 03:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,272,295.15739 seconds with 17 queries