Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file to copy a file  (Read 2329 times)

0 Members and 1 Guest are viewing this topic.

dwiseman3

    Topic Starter


    Newbie

    batch file to copy a file
    « on: May 20, 2009, 12:47:45 PM »
    I want to write a batch file to copy a file from one server to another. The filename changes everyday and includes today's date. How do I incorporate the changing filename into the script?

    ksiemb

    • Guest
    Re: batch file to copy a file
    « Reply #1 on: May 21, 2009, 12:21:44 PM »
    Is the date the only thing that changes in the file name?

    dwiseman3

      Topic Starter


      Newbie

      Re: batch file to copy a file
      « Reply #2 on: May 27, 2009, 08:54:12 AM »
      yes, only the date changes

      Rob Pomeroy



        Prodigy

      • Systems Architect
      • Thanked: 124
        • Me
      • Experience: Expert
      • OS: Other
      Re: batch file to copy a file
      « Reply #3 on: May 27, 2009, 09:55:02 AM »
      Sounds like Robocopy is the boy for you.
      Only able to visit the forums sporadically, sorry.

      Geek & Dummy - honest news, reviews and howtos

      Spoiler



        Specialist

        Thanked: 50
      • Experience: Beginner
      • OS: Windows XP
      Re: batch file to copy a file
      « Reply #4 on: May 27, 2009, 10:13:47 AM »
      You can try this.....


      For /f "tokens=2-4 delims=/ " %%a in ('date/t') do (
      Set month=%%a
      Set day=%%b
      Set year=%%c
      )
      REN D:\Temp\your_file.txt your_file%year%%month%%day%.TXT

      should give you a file called your_file20090527.txt

      Whenever I watch TV and I see those poor starving kids all over the world, I can't help but cry. I mean I would love to be skinny like that, but not with all those flies and death and stuff." - Mariah Carey, Pop Singer