Solved: Command filters

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Holmwood

Thread Starter
Joined
Aug 27, 2008
Messages
7
I use xcopy with the date switch set [/d:mm-dd-yyyy] to backup files changed since that date.

I want to use a command filter to include the date /t command within the xcopy command, so that only files changed on the day the program is run are copied.

Example:

xcopy f:\user\ABC\*.* c:\review\*.* /d: | date/t /s

I have 2 problems getting it working:

1. The date command output is on a new line, so breaking the xcopy command.

2. My local date setting is dd/mm/yy so the date format would be wrong anyway as xcopy date switch wants mm-dd-yy.

Is it possible to use a piped date command within xcopy?
 

Holmwood

Thread Starter
Joined
Aug 27, 2008
Messages
7
After some research and false starts, I found that I could do this by setting a new variable, manipulating the %date% string as follows:

set xdate=%date:~3,2%-%date:~0,2%-%date:~6,4%
xcopy sourcedir\*.* tartgetdir\*.* /d:%xdate%

:D

It would get messy if I wanted the date 3 days ago.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Top