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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:33:17+00:00 2026-06-08T16:33:17+00:00

I’m trying to create a batch file (via Windows XP Pro) that copies 2

  • 0

I’m trying to create a batch file (via Windows XP Pro) that copies 2 files (.zpl) who’s filename’s vary in length. ZPL files relate to label printer code. File names are as follows:

FillXferDataPBHAMFill###########.zpl
FillFormatsPBHAMFill############.zpl

The pound signs represent a number associated with a particular label/job to be printed. These numbers are identical per job. From one job to the next the numbers vary in length and always change. The directory I’m trying to pull these from contains ZPL files from multiple locations, however, I just want the BHAM ones.

The batch will copy from: \Server\C:\Directory1\Directory2\Directory3
To be copied to: \Server\Directory1\Directory2

Not sure if this will complicate things further, but the batch file will be ran from a 3rd machine. Furthermore, I do not need to copy every file everytime. Whenever new print jobs are sent, supervisors will run the batch to copy the new print jobs within the last X amount of time. X being minutes. Here is what I have so far…

@echo off
SETLOCAL enableExtensions enableDelayedExpansion

SET sourceDir=Server\C:\Directory1\Directory2\Directory3
SET targetDir=Server\Directory1\Directory2

FOR %%a (FillFormatsPBHAM*.bat) DO (
SET "filename=%%a"
SET "folder=%targetDir%"
XCOPY "%%a" !folder!
)

FOR %%b (FillXferDataPBHAM*.bat) DO (
SET "filename=%%b"
SET "folder=%targetDir%"
XCOPY "%%b" !folder!
)

:END

I apologize for a lengthy post; just wanting to be as thorough as possible. I’m learning this on the fly so bare with any ignorance on my part. Thank you in advance for ANY help!!

StackOverFlow Material Reviewed: Reference1, Reference2 — I’ve been looking everywhere over the past week and these were the 2 most helpful so far.

  • 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-08T16:33:18+00:00Added an answer on June 8, 2026 at 4:33 pm

    I see some ways to fix or improve your BAT script.

    1. The FOR command syntax is FOR %%a IN (*.bat) DO (

    2. The sourcedir variable is set Server\C:\Directory1\Directory2\Directory3, which is not a correct path in Windows.

    3. you initialize but don’t use %sourcedir% variabe neither in your FOR loop nor in your copy commnand

      you should either change the current drive and dir with a pushd %sourcedir% command, or specifying it in the FOR command.

    4. your FOR loop assigns a %filename% variable that is never used, you may skip this assignment.

    5. you FOR loop assigns a %folder% variable that is only then used in the copy command, you can skip this assignment and simply use %targetdir%

    6. but, to just copy all files from one folder to the other you don’t need FOR to iterate over all of them, you might just copy them right.

    So, take a look at this simple script to get you started..

    SET sourceDir=\\servername\sharename\Directory1\Directory2\Directory3
    SET targetDir=\\anotherserver\sharename\Directory1\Directory2
    xcopy %sourceDir%\FillFormatsPBHAM*.bat %targetDir%
    xcopy %sourceDir%\FillXferDataPBHAM*.bat  %targetDir%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.