I have a list of .rar
files in a network unit which are generated automatically one per day.
What I'm trying to do is generate a .bat
that goes to that network unit and copy the most recent file according to the date of modification or creation with the work better, it should only be the most recent file.
I've tried the following:
@echo off
echo ============INICIANDO PROCESO DE COPIADO=============
echo ......=ACEDIENDO A LA CARPETA DE LOS ARCHIVOS=.......
W:
echo .....................................................
echo ==============EMPEZANDO COPIA DE ARCHIVO=============
set fecha=%date%
xcopy "W:\UnidadDeRed\*.rar" /d:%fecha% "C:\DestinoArchivo\*.rar"
echo .............=COPIA DE ARCHIVO TERMINADA=............
echo =====================================================
pause
In the code I am declaring fecha
and I give it a value using the operator date
so I get the current date, then I use the varible fecha
in the modifier /d:
of the instruction xcopy
the modifier serves to copy files changed during or after the specified date.
Like this one, I get the following error:
The date format of my team is that and the file format is also like this:
If I remove the modifier, copy all the files, which I do not want, but then:
Why that error? How is that switch used?
Is it because the files have time? Some other way?
Thank you in advance