none
Robocopy powershell script to copy files created today RRS feed

  • Question

  • I am trying to copy my backup files which are created on today to another location; seems like there is some sort of error in the script I created

    Robocopy \\source \\destination /s /MAXAGE: "$((Get-Date).ToString('yyyyMMdd')) "

    Thanks in Advance

    Aneesh

    

    

    Wednesday, January 16, 2013 6:27 PM

Answers

  • Aneesh, you could just do /MAXAGE:1 which will only copy today files.

    Robocopy \\source \\destination /s /MAXAGE:1

    or you could try following

    $today = get-date -Format yyyyMMdd
    robocopy \\source \\destination /s /maxage:$today


    MCP, MCTS, MCSE 2003, MCITP 2008, MCSA 2012
    LinkedIn: http://www.linkedin.com/pub/jatin-patel/25/90b/2a/

    This posting is provided 'AS IS' with no warranties or guarantees and confers no rights.
    Please help and appreciate others by using these features: "Propose As Answer", "Vote As Helpful" and "Mark As Answer"



    • Edited by pateljy Wednesday, January 16, 2013 8:05 PM
    • Marked as answer by Aneesh Ret Wednesday, January 16, 2013 8:50 PM
    Wednesday, January 16, 2013 8:02 PM

All replies

  • Aneesh, you could just do /MAXAGE:1 which will only copy today files.

    Robocopy \\source \\destination /s /MAXAGE:1

    or you could try following

    $today = get-date -Format yyyyMMdd
    robocopy \\source \\destination /s /maxage:$today


    MCP, MCTS, MCSE 2003, MCITP 2008, MCSA 2012
    LinkedIn: http://www.linkedin.com/pub/jatin-patel/25/90b/2a/

    This posting is provided 'AS IS' with no warranties or guarantees and confers no rights.
    Please help and appreciate others by using these features: "Propose As Answer", "Vote As Helpful" and "Mark As Answer"



    • Edited by pateljy Wednesday, January 16, 2013 8:05 PM
    • Marked as answer by Aneesh Ret Wednesday, January 16, 2013 8:50 PM
    Wednesday, January 16, 2013 8:02 PM
  • Thanks.MaxAge wont work in my case because the script is going to be part of an hourly job; that's why i was looking to pass today as part of the statement.
    • Edited by Aneesh Ret Wednesday, January 16, 2013 8:53 PM
    Wednesday, January 16, 2013 8:51 PM