Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-07-2009
Member
 
Join Date: May 2009
Posts: 533
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.
Reply With Quote
  #2  
Old 15-07-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Retrieving the current directory in batch

Here's the code to get hold of the current directory:
Quote:
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.
Reply With Quote
  #3  
Old 15-07-2009
Member
 
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.
Reply With Quote
  #4  
Old 15-07-2009
Member
 
Join Date: May 2009
Posts: 533
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 03:55 AM.