What switch for Copy today's files only

  • Thread starter Thread starter Tim Jol
  • Start date Start date
T

Tim Jol

I want to copy files from e:\*.log to d:\*.log only that
are created today. I dont' find any switch. Is there a
way? (I cannot hardcode the /D:ddmmyy function as in
XCOPY as my COPY procedure runs from a batch file at
scheduled time)
 
Tim Jol said:
I want to copy files from e:\*.log to d:\*.log only that
are created today. I dont' find any switch. Is there a
way? (I cannot hardcode the /D:ddmmyy function as in
XCOPY as my COPY procedure runs from a batch file at
scheduled time)

i often use "pkzip" utility that has very simple flagg "-t" which means
"today". after zip is created [with selected today's files] you may
"explode" it or keep it zipped [for space saving purposes]
 
Tim Jol said:
I want to copy files from e:\*.log to d:\*.log only that
are created today. I dont' find any switch. Is there a
way? (I cannot hardcode the /D:ddmmyy function as in
XCOPY as my COPY procedure runs from a batch file at
scheduled time)

If you really mean TODAY and not yesterday you can use use Xcopy's date
switch like this
/d:%DATE:~4%
 
Tim Jol said:
I want to copy files from e:\*.log to d:\*.log only that
are created today. I dont' find any switch. Is there a
way? (I cannot hardcode the /D:ddmmyy function as in
XCOPY as my COPY procedure runs from a batch file at
scheduled time)e

Attention! AFAIK the switch uses /D:mm-dd-yy(yy).

w2k or newer have the environment var %date%
See also :http://www.ss64.com/nt/date.html

xcopy source dest /D:%date:~4,2%-%date:~7,2%-%date:~10,4%

should do, to test include the list only switch /L

HTH
 
Matthias Tacke said:
Attention! AFAIK the switch uses /D:mm-dd-yy(yy).

mm/dd/yyyy works for me. Been using it for a long time. Give it a try. I'm
not sure if it works with other regional/local date formats though. I have
no way to check that.
 
Paul R. Sadowski said:
mm/dd/yyyy works for me. Been using it for a long time. Give it a try. I'm
not sure if it works with other regional/local date formats though. I have
no way to check that.
Same with me ;-)

A lot easier if xcopy accepts the slashes. OTOH of no uese for most
europeans since we have to change the month/day order.

The table in the mentioned link lacks the normal date output with the
abbreviated day name, which in germany has only two places.
 
Matthias Tacke said:
The table in the mentioned link lacks the normal date output with the
abbreviated day name, which in germany has only two places.

Ah, OK. Thanks. I didn't know that. I assumed at least that was standard
across the world.
 
Thanks Mat and Paul.

Does this take care a situation like this: Copy a FOLDER
that is created TODAY from source to destination. This
folder may contain some old dated files also. The result
expected is validation should occur at the folder level
and enire folder should be copeid to destination.
 
Tim Jol said:
Thanks Mat and Paul.

Does this take care a situation like this: Copy a FOLDER
that is created TODAY from source to destination. This
folder may contain some old dated files also. The result
expected is validation should occur at the folder level
and enire folder should be copeid to destination.

No, xcopy only looks at file timestamps.
 
In microsoft.public.win2000.cmdprompt.admin Paul R. Sadowski [MVP]
wrote:
No, xcopy only looks at file timestamps.

Perhaps the directory created "today" is like "2004-10-04" and the
validation of "today" is made by name instead of date attributes...
 
Thanks Mat and Paul.

Does this take care a situation like this: Copy a FOLDER
that is created TODAY from source to destination. This
folder may contain some old dated files also. The result
expected is validation should occur at the folder level
and enire folder should be copeid to destination.

Using 4NT, this command might do what you want:
FOR /[dc-0] /A:D %dn IN (*.*) (MD targetdir\%dn %+ COPY %dn\*.* targetdir\%dn)

It enumerates all directories created today, and for each it creates a
subdirectory of that name in targetdir and copies all files from the
source subdirectory to the newly created target subdirectory.

4NT is a commercial product; however, the syntax above should also
work with 4DOS which is free and can run under NTx.x .
 
Back
Top