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

  • Home
  • SEARCH
  • 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 8739415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:56:02+00:00 2026-06-13T10:56:02+00:00

I need to implement a function in a Windows batch script to get the

  • 0

I need to implement a function in a Windows batch script to get the LastIndexOf a character into a given string.

For example: Given the following string, I need to get the last index of character '/':

/name1/name2/name3
            ^

So I need to get the value:

12
  • 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-06-13T10:56:03+00:00Added an answer on June 13, 2026 at 10:56 am

    (Note: I’m assuming Windows batch files because, frankly, I have only seen a single question asking for an actual DOS batch file here so far. Most people simply misattribute “DOS” to anything that has a window of gray-on-black monospaced text without knowing what they’re actually talking of.)

    Just loop through it, updating the index as you go:

    @echo off
    setlocal enabledelayedexpansion
    set S=/name1/name2/name3
    set I=0
    set L=-1
    :l
    if "!S:~%I%,1!"=="" goto ld
    if "!S:~%I%,1!"=="/" set L=%I%
    set /a I+=1
    goto l
    :ld
    echo %L%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to implement a function for moving records up and down (sorting) and
If we need to implement a function that takes an array of integers and
I need to implement an auxilliary function, named copyList, having one parameter, a pointer
I need to implement a simp^le find function which will retrieve the 1st occurence
I need to chose the right implement for calling a function foo than written
To implement github like fork/pull request function in my project, the auto-merge feature need
I am trying to implement in windows scripting host the same function as windows
In an almost complete effort to port libc++ to Windows, I need the function
I need to implement some new functions on an editor. I picked Emacs -
There is a good function that I need, which is implemented in the Java

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.