Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > up two folders in a batch file

Reply
Thread Tools Display Modes

up two folders in a batch file

 
 
Greg Stigers
Guest
Posts: n/a

 
      10-19-2009
I'm using %~dP0 to identify the path from which a batch file is run. I need
to write a log, up two levels, and then down two folders. And I need to let
the user know exactly where that is.

I can code %~dP0..\..\dir\subdir, but don't expect the user to understand
what that means. I've toyed with a couple of ideas, all kludgy and obtuse.
Is there a way way to do this, that isn't ugly?
______
Greg Stigers, MCSE
remember to vote for the answers you like


 
Reply With Quote
 
 
 
 
Greg Stigers
Guest
Posts: n/a

 
      10-19-2009

I know about %~dp0, but not %~dpa. Can you explain that one a bit? Web
searching on ~ is disappointing.

"Tom Lavedas" <> wrote in message
news:735ff201-b92c-46ba-8f6e-...
> Have you considered something like this ...


> for %%a in ("%~dp0\..") do set folder=%%~dpadir\subdir
> echo %folder%
> _____________________
> Tom Lavedas



 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      10-20-2009

"Greg Stigers" <gregstigers+> wrote in message
news:#...
> I'm using %~dP0 to identify the path from which a batch file is run. I
> need to write a log, up two levels, and then down two folders. And I need
> to let the user know exactly where that is.
>
> I can code %~dP0..\..\dir\subdir, but don't expect the user to understand
> what that means. I've toyed with a couple of ideas, all kludgy and obtuse.
> Is there a way way to do this, that isn't ugly?
> ______
> Greg Stigers, MCSE
> remember to vote for the answers you like


This should do the trick for you, assuming that the batch file is being run
from a real or mapped drive rather than from a UNC:


pushd %~dP0..\..\dir\subdir
(set logFileFolder=%cd%)
popd
echo/look for the log file here: "%lofFileFolder%"

/Al


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dos batch file to sort files based on file names. Jon Osborn Scripting 8 06-17-2009 05:36 AM
batch renaming folders including subfolders name Windows Vista General Discussion 1 05-30-2007 04:39 PM
remotely executed script calls batch file that redirects output to a txt file reference by UNC path Breck Scripting 2 11-02-2004 06:00 PM
List shared folders from a batch script George Valkov Scripting 13 10-12-2004 10:04 PM
Batch file to keep track of file size and generate email Phil McNeill Scripting 2 11-10-2003 08:04 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59