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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:28:21+00:00 2026-05-15T11:28:21+00:00

This batch file releases a build from TEST to LIVE. I want to add

  • 0

This batch file releases a build from TEST to LIVE. I want to add a check constraint in this file that ensures there is an accomanying release document in a specific folder.

"C:\Program Files\Windows Resource Kits\Tools\robocopy.exe" "\\testserver\testapp$"        
"\\liveserver\liveapp$" *.* /E /XA:H /PURGE /XO /XD ".svn" /NDL /NC /NS /NP
del "\\liveserver\liveapp$\web.config"
ren "\\liveserver\liveapp$\web.live.config" web.config

So I have a couple of questions about how to achieve this…

  1. There is a version.txt file in the \\testserver\testapp$ folder, and the only contents of this file is the build number (for example, 45 – for build 45)
    How do I read the contents of the version.txt file into a variable in the batch file?

  2. How do I check if a file ,\\fileserver\myapp\releasedocs\ {build}.doc, exists using the variable from part 1 in place of {build}?

  • 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-15T11:28:22+00:00Added an answer on May 15, 2026 at 11:28 am

    Read file contents into a variable:

    for /f "delims=" %%x in (version.txt) do set Build=%%x
    

    or

    set /p Build=<version.txt
    

    Both will act the same with only a single line in the file, for more lines the for variant will put the last line into the variable, while set /p will use the first.

    Using the variable – just like any other environment variable – it is one, after all:

    %Build%
    

    So to check for existence:

    if exist \\fileserver\myapp\releasedocs\%Build%.doc ...
    

    Although it may well be that no UNC paths are allowed there. Can’t test this right now but keep this in mind. Note that with the set /P command the file cannot be in Unicode format.

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

Sidebar

Related Questions

I'm running this small C# test program launched from a pre-commit batch file private
while loading getfptex(got it from CTAN) batch file ,when i'm extracting this batch file
Using this batch file I want zip some *.txt files. Each *.txt file in
I have a batch file that I can't change, but I want to automate
Im trying to make this batch script check on resumption that it has not
I have this batch file that outputs a list of all the tables to
I want to create a batch file, batch.bat , that accepts 2 mandatory arguments:
I have written huge MS DOS Batch file. To test this batch file I
Got this batch file which does exactly what I want, however I don't fully
I have this batch file to export two files from svn. But it never

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.