What switch for Copy today's files only


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)
 
Ad

Advertisements

G

gabor salai

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]
 
P

Paul R. Sadowski [MVP]

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%
 
M

Matthias Tacke

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
 
P

Paul R. Sadowski [MVP]

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.
 
M

Matthias Tacke

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.
 
Ad

Advertisements

P

Paul R. Sadowski [MVP]

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.
 
T

Tim Jol

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.
 
P

Paul R. Sadowski [MVP]

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.
 
M

Mark V

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...
 
Ad

Advertisements

M

Michael Bednarek

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 .
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top