1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Command filters

Discussion in 'DOS/Other' started by Holmwood, Sep 21, 2008.

Thread Status:
Not open for further replies.
  1. Holmwood

    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?
     
  2. Holmwood

    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.
     
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/751906

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice