Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:18+00:00 2026-05-23T09:04:18+00:00

This works when the file is called from the same directory where it it

  • 0

This works when the file is called from the same directory where it it is placed:

    @ECHO OFF
    set _MyCurrentPath=%CD%
    pushd ..
    set _Level1UpDir=%CD%
    ECHO _Level1UpDir: %_Level1UpDir%
    pushd ..
    set _Level2UpDir=%CD%
    ECHO _Level2UpDir: %_Level2UpDir%
    pushd ..
    set _Level3UpDir=%CD%
    ECHO _Level3UpDir: %_Level3UpDir%
    PAUSE

Yet how-to get the n-th level up just from the %0 … it would requre some fancy call with for /f %%in

My strategy was to count the number of backslashes and the a second for loop as follows:
SET count=1
FOR /f “tokens=1-4 delims=.” %%G IN (‘echo %0’) DO (call :subroutine “%%G”)
GOTO :eof

:subroutine
echo %count%:%1
set /a count+=1
pause
GOTO :eof
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:04:18+00:00Added an answer on May 23, 2026 at 9:04 am

    What’s wrong with the path .\..\..\.. (repeat .. as much as you like, in a loop) ?

    Here is batch code to repeat a string N times

    If you need the fully expanded path, you could try tilde-expansion. Eg: %~dp0 will be %0 expanded to a full path.

    I often put CD %~dp0 near the top of my batch files if they contain paths relative to the batch file itself.

    Thus you could use %~dp0\..\..\.. to get the full path and then 3 up from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works when I try it from a .py file, but fails in
I am accessing custom UIComponent via SWC file from Flex 3. This component works
I'm trying to work this out. In my project, i have a file called
with MVS2008, this line works fine: _fsopen(file_name, wb+, _SH_DENYRW); Borland C++builderX from 2003 complains
I am using ASP.NET to transmit a .jar file. This code works perfectly on
I have this script to generate an XML file for an RSS feed. Works
I have this code to write to a file, it works perfect but I
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
For a Facebook iframe app, we load a file browser Java applet. This works
I have the this code that will create excel file and work sheet then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.