BAT to Copy Files with certain word in file and append new extension

Home Forums Scripting DOS Command Shell BAT to Copy Files with certain word in file and append new extension

This topic contains 1 reply, has 2 voices, and was last updated by Avatar BYAKUBOV 3 years, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #166642

    Update I have a semi working code, I just need to only copy files from today
    Here is what I have
    xcopy “C:TEST1*.EDI832*” “C:TEST2*.EDI832”

    This is copying all and renaming I just need to narrow it down to the day of run, I have recreate this for many paths.
    in the end I will be taking file 1 and copying it to 9 different locations and this will be done to 9 different files each day. so the simpler the better.

    Okay I am fairly new to writing Bat Files. But I need to Copy files from one folder to another, but only files with a certain word in the name and modified the day of run. I also need to append a new extension to the file.
    So example
    To take a file like this with EDI832 in the name (Must be day of Run)
    D:WORKOP1123456.hhh222333.EDI832.processed.201 61018185223

    and Copy to and append new extension like so
    D:WORKOP2123456.hhh222333.EDI832.processed.201 61018185223.EDI832

    I can copy files just fine, but I can’t figure out how to grab only certain types of files and also append an extension.

    Any help would be appreciated.


    Use the /d switch and specify the date like /d:10-22-2016. You can also get the date from the %date% environment variable. Do some searches on how to parse off the day as I’m sure someone has done it before. Once you have the date into a variable, you can use that in your xcopy command so it will always pick up the current date of the system and automatically use that.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.