1.

Solve : Xcopy with dynamic file name as parameter?

Answer»

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.

Code: [Select]@echo off
for %%a in (*tfile.txt) do xcopy "%%a" "d:\target\"



Discussion

No Comment Found