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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:08:02+00:00 2026-05-23T14:08:02+00:00

I seem to be stuck with a batch script and would like some help.

  • 0

I seem to be stuck with a batch script and would like some help.

Basically I need to check if a file exists in a folder in the %localappdata% and if it does then overwrite the file and if not place inside a different location so at the moment it reads like this:

IF EXIST "%localappdata%\foldername\filename" COPY /Y "filename" "location" ELSE COPY "filename" "location2" 

But when this runs I’m receiving an error of The syntax of the command is incorrect. This seems to be down to the %localappdata% variable being used.

Thank you in advance for any help on this.

  • 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-23T14:08:03+00:00Added an answer on May 23, 2026 at 2:08 pm

    You need to put the two commands for the IF branches in parens:

    IF EXIST "%localappdata%\foldername\filename" (COPY /Y "filename" "location") ELSE (COPY "filename" "location2")
    

    The reason for this is that the shell needs to be able to tell that if the file does exist, the command you want to run is just this:

    COPY /Y "filename" "location"
    

    and not all of this:

    COPY /Y "filename" "location" ELSE COPY "filename" "location2"
    

    If you think about it, all those ELSE COPY stuff may very well be legitimate parameters for the first COPY — the shell has no way to know unless you help.

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

Sidebar

Related Questions

Hi everybody I seem to be stuck and I hope you guys can help
i've been stuck on a problem and can't seem to find any help for
Stuck with an unusual problem, would seem that I love doing things that's not
This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying
I'm trying to learn some Rails but I seem to get stuck on this
I seem to be stuck in Kafka-land, with a java.lang.String that I can't seem
This is a followup to this question . I seem to be stuck on
I seem to be mentally stuck in a Flyweight pattern dilemma. First, let's say
I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck
I seem to be missing something about LINQ. To me, it looks like it's

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.