<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting the current working directory from DOS or Batch file</title>
	<atom:link href="http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Pratap Reddy</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-125966</link>
		<dc:creator>Pratap Reddy</dc:creator>
		<pubDate>Thu, 08 Dec 2011 04:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-125966</guid>
		<description>This is one of the useful post.
I wanted to copy the assembly from one folder to another folder without any knowledge of location of the parent folder. All i needed to do is as below
COPY /Y &quot;%cd%Folder1Folder2Folder3binDebugaaAutoControlIdentifierLib.dll&quot; &quot;%cd%Dlls&quot;</description>
		<content:encoded><![CDATA[<p>This is one of the useful post.<br />
I wanted to copy the assembly from one folder to another folder without any knowledge of location of the parent folder. All i needed to do is as below<br />
COPY /Y &#8220;%cd%Folder1Folder2Folder3binDebugaaAutoControlIdentifierLib.dll&#8221; &#8220;%cd%Dlls&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: llbbl</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-125731</link>
		<dc:creator>llbbl</dc:creator>
		<pubDate>Wed, 26 Oct 2011 21:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-125731</guid>
		<description>awesome thanks!</description>
		<content:encoded><![CDATA[<p>awesome thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chupakabra</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-124611</link>
		<dc:creator>Chupakabra</dc:creator>
		<pubDate>Thu, 07 Jul 2011 10:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-124611</guid>
		<description>Once more with feeling...

Now take the case of a WinCE device not providing delayed expansion and not providing FOR either (welcome to hell)

only %0 is mainly available here.

The only solution I could see is the following:
- get the %0
- MKDIR a folder with some added characters to your batch filename (nasty)
- CD  NEWDIR..
- RMDIR NEWDIR

This is awfull but provides a solution, no need to say it&#039;s not even reliable if you are on a ReadOnly partition (pretty rare within this context imho).

any comments on this?</description>
		<content:encoded><![CDATA[<p>Once more with feeling&#8230;</p>
<p>Now take the case of a WinCE device not providing delayed expansion and not providing FOR either (welcome to hell)</p>
<p>only %0 is mainly available here.</p>
<p>The only solution I could see is the following:<br />
- get the %0<br />
- MKDIR a folder with some added characters to your batch filename (nasty)<br />
- CD  NEWDIR..<br />
- RMDIR NEWDIR</p>
<p>This is awfull but provides a solution, no need to say it&#8217;s not even reliable if you are on a ReadOnly partition (pretty rare within this context imho).</p>
<p>any comments on this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Vasiljevs</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-123666</link>
		<dc:creator>Mike Vasiljevs</dc:creator>
		<pubDate>Tue, 31 May 2011 10:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-123666</guid>
		<description>many a million ben. 

Problem: use xcopy without File/Directory prompt

e.g. entry is &quot;dirfile.txt&quot;, discard filename to get &quot;dir&quot;

Solution:

given  

source_dir = &quot;d:source&quot; 

and 

target_dir = &quot;c:tmpsource&quot; 

script below 
----------------
set some_file_entry=dirfile.txt
set dst_file=%target_dir%%some_file_entry%

for %%f in (%dst_file%) do (
    xcopy %source_dir%%some_file_entry% %%~df%%~pf
)
------------------------
will copy:

&quot;d:sourcedirfile.txt&quot; -&gt; &quot;c:tmpsourcedirfile.txt&quot; 

without &quot;(F = file, D = directory)? &quot; bullsh*t!!!</description>
		<content:encoded><![CDATA[<p>many a million ben. </p>
<p>Problem: use xcopy without File/Directory prompt</p>
<p>e.g. entry is &#8220;dirfile.txt&#8221;, discard filename to get &#8220;dir&#8221;</p>
<p>Solution:</p>
<p>given  </p>
<p>source_dir = &#8220;d:source&#8221; </p>
<p>and </p>
<p>target_dir = &#8220;c:tmpsource&#8221; </p>
<p>script below<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
set some_file_entry=dirfile.txt<br />
set dst_file=%target_dir%%some_file_entry%</p>
<p>for %%f in (%dst_file%) do (<br />
    xcopy %source_dir%%some_file_entry% %%~df%%~pf<br />
)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
will copy:</p>
<p>&#8220;d:sourcedirfile.txt&#8221; -&gt; &#8220;c:tmpsourcedirfile.txt&#8221; </p>
<p>without &#8220;(F = file, D = directory)? &#8221; bullsh*t!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-120641</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 14 Apr 2011 08:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-120641</guid>
		<description>%0! Who knew? Thanks @Adam.

This page is still coming up in searches so, I&#039;ll just add that if you want just the current folder, you&#039;ll have to extract it from the path yourself:
(you&#039;ll need delayed expansion enabled for this)

call :getCurrentFolder &quot;%~1&quot; strPath

...

:getCurrentFolder
setlocal
  set ret=%~1
  if &quot;!ret!&quot; equ &quot;&quot; (
    set ret=
  ) else if &quot;!ret:~-1!&quot; equ &quot;\&quot; (
    set ret=
  ) else (
    call :getCurrentFolder &quot;!ret:~0,-1!&quot; folder
    set ret=!folder!!ret:~-1!
  )
endlocal&amp;set %2=%ret%</description>
		<content:encoded><![CDATA[<p>%0! Who knew? Thanks @Adam.</p>
<p>This page is still coming up in searches so, I&#8217;ll just add that if you want just the current folder, you&#8217;ll have to extract it from the path yourself:<br />
(you&#8217;ll need delayed expansion enabled for this)</p>
<p>call :getCurrentFolder &#8220;%~1&#8243; strPath</p>
<p>&#8230;</p>
<p>:getCurrentFolder<br />
setlocal<br />
  set ret=%~1<br />
  if &#8220;!ret!&#8221; equ &#8220;&#8221; (<br />
    set ret=<br />
  ) else if &#8220;!ret:~-1!&#8221; equ &#8220;\&#8221; (<br />
    set ret=<br />
  ) else (<br />
    call :getCurrentFolder &#8220;!ret:~0,-1!&#8221; folder<br />
    set ret=!folder!!ret:~-1!<br />
  )<br />
endlocal&amp;set %2=%ret%</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-45461</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Fri, 20 Aug 2010 20:53:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-45461</guid>
		<description>Still no way to get JUST the current directory name, not the full path!  :(</description>
		<content:encoded><![CDATA[<p>Still no way to get JUST the current directory name, not the full path!  <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott D</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-43739</link>
		<dc:creator>Scott D</dc:creator>
		<pubDate>Sat, 07 Aug 2010 03:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-43739</guid>
		<description>Thank you for your article. I also found these 2 commands below were good for finding the current directory and making it come up in Notepad, so you can copy and paste it:
cd &gt; filepath.txt
filepath.txt &#124; more</description>
		<content:encoded><![CDATA[<p>Thank you for your article. I also found these 2 commands below were good for finding the current directory and making it come up in Notepad, so you can copy and paste it:<br />
cd &gt; filepath.txt<br />
filepath.txt | more</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Agostino</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-41331</link>
		<dc:creator>Agostino</dc:creator>
		<pubDate>Tue, 13 Jul 2010 13:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-41331</guid>
		<description>Many thanks, it works!</description>
		<content:encoded><![CDATA[<p>Many thanks, it works!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Luplow</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-41124</link>
		<dc:creator>Ben Luplow</dc:creator>
		<pubDate>Sun, 11 Jul 2010 05:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-41124</guid>
		<description>For a complete list of the variable commands type for /? in cmd and they are all a few pages down.
 In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (&quot;)
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be combined to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.</description>
		<content:encoded><![CDATA[<p>For a complete list of the variable commands type for /? in cmd and they are all a few pages down.<br />
 In addition, substitution of FOR variable references has been enhanced.<br />
You can now use the following optional syntax:</p>
<p>    %~I         &#8211; expands %I removing any surrounding quotes (&#8220;)<br />
    %~fI        &#8211; expands %I to a fully qualified path name<br />
    %~dI        &#8211; expands %I to a drive letter only<br />
    %~pI        &#8211; expands %I to a path only<br />
    %~nI        &#8211; expands %I to a file name only<br />
    %~xI        &#8211; expands %I to a file extension only<br />
    %~sI        &#8211; expanded path contains short names only<br />
    %~aI        &#8211; expands %I to file attributes of file<br />
    %~tI        &#8211; expands %I to date/time of file<br />
    %~zI        &#8211; expands %I to size of file<br />
    %~$PATH:I   &#8211; searches the directories listed in the PATH<br />
                   environment variable and expands %I to the<br />
                   fully qualified name of the first one found.<br />
                   If the environment variable name is not<br />
                   defined or the file is not found by the<br />
                   search, then this modifier expands to the<br />
                   empty string</p>
<p>The modifiers can be combined to get compound results:</p>
<p>    %~dpI       &#8211; expands %I to a drive letter and path only<br />
    %~nxI       &#8211; expands %I to a file name and extension only<br />
    %~fsI       &#8211; expands %I to a full path name with short names only<br />
    %~dp$PATH:I &#8211; searches the directories listed in the PATH<br />
                   environment variable for %I and expands to the<br />
                   drive letter and path of the first one found.<br />
    %~ftzaI     &#8211; expands %I to a DIR like output line</p>
<p>In the above examples %I and PATH can be replaced by other valid<br />
values.  The %~ syntax is terminated by a valid FOR variable name.<br />
Picking upper case variable names like %I makes it more readable and<br />
avoids confusion with the modifiers, which are not case sensitive.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit Bhatia</title>
		<link>http://www.markhneedham.com/blog/2008/08/12/getting-the-current-working-directory-from-dos-or-batch-file/comment-page-1/#comment-34883</link>
		<dc:creator>Amit Bhatia</dc:creator>
		<pubDate>Fri, 09 Apr 2010 08:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=87#comment-34883</guid>
		<description>Thanks @Adam. Your instructions helped to create custom print folder bat file.</description>
		<content:encoded><![CDATA[<p>Thanks @Adam. Your instructions helped to create custom print folder bat file.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

