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 7967005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:35:02+00:00 2026-06-04T06:35:02+00:00

I am working on a batch file to use as a wrapper for some

  • 0

I am working on a batch file to use as a wrapper for some data processing modules that are already written, with the goal of being able to run some in parallel and others serially as needed/processing power allows. The underlying modules require one input (a path contained in double quotes), and optionally another path contained in double quotes and/or a set of flags, and I am trying to figure out how to test these inputs. I currently have

:TEST_PARAMS
REM Make sure parameters are correct; if not, display a usage message
IF NOT "%1"=="" (SET SUBBASENAME=%1
) ELSE (
    GOTO :USAGE
)
IF NOT "%2"=="" (SET ATLASBASENAME=%2
) ELSE (
    SET ATLASBASENAME=%DEFAULTATLAS%
)
IF NOT "%3"=="" (SET FLAGS=%3
) ELSE (
    SET FLAGS=""
)
GOTO :START_SVREG

This seems to parse everything correctly if things are input in the correct order. However, I also wanted to check if the flags (which will be preceeded by ‘-‘) are popping up as the first or second inputs, and if they are, to display a usage message/set the variables correctly as needed. I figured the easiest way to do this would be to see if the first character of these strings is a ‘-‘, but I can’t find any way to do this. I found a snippet of code that checks if a string contains a certain substring by replacing the substring with empty strings and then seeing if the resulting string is the same as the original, but this wouldn’t work as people might legitimately have hyphens somewhere else in their path(s). Is there a way to check whether the first character of a string matches a given character in a batch file, or a better way of doing what I want?

  • 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-04T06:35:04+00:00Added an answer on June 4, 2026 at 6:35 am

    You can transfer the argument to an environment variable, and then use a SET substring operation to look at the first character. (Type HELP SET from the command line to get info about substring operations)

    @echo off
    set "var=%~1"
    if defined var if "%var:~0,1%" equ "-" echo arg 1 is a flag
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a batch file that runs some SELECT queries using sqlcmd, puts the
I'm working on a Windows batch file that will bcp three text files into
I am working on a batch file to gather the mac addresses of two
I had a problem with set not working in a batch file; it took
I want my classpath to be set via a batch file. I'm working on
I am trying to modify a batch script that installs a simple script file
i have the following batch file, which terminates the iTunes program so, that if
I am working within a batch file and need to pad a single digit
I'd like to write a batch file that checks to see if a process
Hey there. Basically, I have a batch-file, that goes through all model and texture

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.