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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:59:04+00:00 2026-06-03T22:59:04+00:00

So for example i need to check if file C:\windows\system32\whatever.dll lies in c:\windows. Is

  • 0

So for example i need to check if file C:\windows\system32\whatever.dll lies in c:\windows. Is it possible in a manner like if not exists ..., but here if %file% lies in %directory% ?

edit: I know the path to the file I’m looking for. The problem boils down to comparing strings, that is checking if path to the directory is contained at the beginning in a path to the file.

  • 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-03T22:59:05+00:00Added an answer on June 3, 2026 at 10:59 pm

    you can do something like

    if not exists %directory%\%file% 
    

    in this way you create a full file-pathname like “c:\myfolder\yourfolder\myfile.txt” and check for it’s existence

    Update
    this should works (but it’s not tested)

    :: starting folder
    set RootPath=c:\myfolder\yourfolder\
    
    ::check all subfolder
    for /R "%RootPath%" %%d IN (.) DO ( 
        echo %%d
    
        :: check all file in each subfolder
        for %%f IN ("%%~d\*.*") DO (
    
            :: check if your file exist 
            IF "%%~nxf"=="filenameImLookingFor.txt" (
                  echo Found file here "%%~f"
            )
        )
    )
    
    • %%~nxf will expand to filname with extension, without the path
    • the “~” make also sure that the expanded variable will never contain
      prefix/postfix doublequte, so that you can add your own without
      having unexpected double-doublequote (that will obviously mess things
      up)

    Here is a list of useful syntax for FOR variables (from the help of the FOR command)

    You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to check if a file exists on a server using delphi.. The
So I'm need to check whether a file exists before showing specific data to
I need to check if a file exists on my server without using cache.
I check the file extension for upload or not uploaded. My example methods worked,
I need an example pom file to create a jar file for my spring
I need a version control system that works like Subversion but is able to
I have an Excel file that contains some values. I need to check if
For example I need to disable two buttons in runtime. After I disabled first
For example I need to grab from http://gmail.com/ the number of free storage: Over
A specific example I need to generate a random number between 0 and 2,

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.