Announcement

Collapse
No announcement yet.

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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

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

    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:\WORK\OP1\0123456.hhh222333.EDI832.processed.201 61018185223

    and Copy to and append new extension like so
    D:\WORK\OP2\0123456.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.
    Last edited by smedwards1178; 19th October 2016, 04:10.

  • #2
    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.

    Comment

    Working...
    X