Computer Hope
Microsoft => Microsoft DOS => Topic started by: Osoful on August 20, 2012, 08:55:35 PM
-
I need to copy a file from one directory to another directory using xcopy. The file that I need to copy is always named differently based on the date it was created.
My questions are:
a)how can I construct the file name dynamically, e.g. 2012-08-08-tfile.txt
and
b) can I pass this file name to xcopy
Thanks for your help.
-
Does the file always have tfile in the name?
Is the file the only .txt file in the folder?
-
yes, it's always tfile at the end. it's currently not the only file in the directory but I could set it up that way if it makes it easier.
-
Then this should work from the same folder.
@echo off
for %%a in (*tfile.txt) do xcopy "%%a" "d:\target\"