Computer Hope

Microsoft => Microsoft Windows => Windows XP => Topic started by: dwiseman3 on May 20, 2009, 12:47:45 PM

Title: batch file to copy a file
Post by: dwiseman3 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?
Title: Re: batch file to copy a file
Post by: ksiemb on May 21, 2009, 12:21:44 PM
Is the date the only thing that changes in the file name?
Title: Re: batch file to copy a file
Post by: dwiseman3 on May 27, 2009, 08:54:12 AM
yes, only the date changes
Title: Re: batch file to copy a file
Post by: Rob Pomeroy on May 27, 2009, 09:55:02 AM
Sounds like Robocopy (http://en.wikipedia.org/wiki/Robocopy) is the boy for you.
Title: Re: batch file to copy a file
Post by: Spoiler 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