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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:05:01+00:00 2026-05-12T08:05:01+00:00

How would one go best about checking for existence of all files before building?

  • 0

How would one go best about checking for existence of all files before building?

Let me explain; I mostly build stuff from the command prompt. No problems there, just put the build command and all in one .bat /.cmd file, and run it. It works fine.

But, for the normal running of my program, for example, I need several source files for the build, and then an additional few data files, measured data and such.

Is there a way to test via a batch file whether a file exists, and if it exists just write OK?

file1.for OK
file2.for OK
datafile.txt OK
data.dat MISSING FROM DIRECTORY

How could this be accomplished?

  • 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-12T08:05:01+00:00Added an answer on May 12, 2026 at 8:05 am

    As a slightly more advanced approach:

    @Echo Off
    SetLocal EnableExtensions EnableDelayedExpansion
    Set FileList=file1.for file2.for "File with spaces" ...
    Set Build=1
    For %%f In (%FileList%) Do Call :FileExists %%f
    
    If Not Defined Build (
        Echo.
        Echo Build aborted. Files were missing.
        GoTo :EOF
    )
    
    ...
    
    GoTo :EOF
    
    :FileExists
    Set FileName=%~1
    If Exist "!FileName!" (
        Echo !FileName! OK
    ) Else (
        Echo !FileName! MISSING FROM DIRECTORY
        Set Build=
    )
    GoTo :EOF
    

    You can put all files into the FileList variable. The Build variable controls whether to continue with the build. A single missing file causes it to cancel.

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

Sidebar

Related Questions

How would one go about proving to management that a batch reformat of all
What would be the best way to combine the two SQL statements into one?
How would one go about either using the 3D components of WPF or using
how would one go about writing the contents of a structure in C++ to
I hope many of you would have heard about Flipboard . One of the
I am building a bi-lingual website and am wondering about the best design to
Normally one would build a related model instance through its parent object: @child =
How would one go about creating a 'beat box' style sound engine, where a
I would like to ask about best practices or the simplest way possible of
How would one enumerate the installed browsers on an OS X system from a

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.