none
robocopy RRS feed

  • Question

  • Hi everyone i need i help if isìt possible.
    this is my question:

    copy from path A to path B:
    only folders starting with name: a01 and only folders created from date: 01/06/2019, no need to copy data inside and subdirectory.

    I add this option on script:

    $source = "C:\tmp\"
    $dest = "C:\test2"
    robocopy $source $dest /LEV:2 /MINAGE:2 /XD /e /xf *.*

    but the swtich MINAGE:2 (if i understand works only for file not for directory).
    there is someone can help me to accomplish this?

    thank's in advantage

    Tuesday, July 2, 2019 2:02 PM

Answers

  • Try powershell:

    [datetime]$limit = "01/06/2019"
    $source = "C:\tmp\"
    $dest = "C:\test2\"
    
    
    
    Get-ChildItem $source -Directory | ?{$_.Name -like "a01*" -and $_.CreationTime -ge $limit} | Copy-Item -Destination $dest
    

    • Edited by DumbleD0re Tuesday, July 2, 2019 2:48 PM
    • Marked as answer by francesco72 Tuesday, July 2, 2019 3:34 PM
    Tuesday, July 2, 2019 2:47 PM

All replies

  • Start by reading the instructions on how to use RoboCopy.

    RoboCopy /? | Out-GridView

    This is not a RoboCopy forum.

    Directories do not have an AGE property.  The dates reflect the latest change to the contents.  RoboCopy only looks at file dates.


    \_(ツ)_/

    Tuesday, July 2, 2019 2:37 PM
  • Try powershell:

    [datetime]$limit = "01/06/2019"
    $source = "C:\tmp\"
    $dest = "C:\test2\"
    
    
    
    Get-ChildItem $source -Directory | ?{$_.Name -like "a01*" -and $_.CreationTime -ge $limit} | Copy-Item -Destination $dest
    

    • Edited by DumbleD0re Tuesday, July 2, 2019 2:48 PM
    • Marked as answer by francesco72 Tuesday, July 2, 2019 3:34 PM
    Tuesday, July 2, 2019 2:47 PM
  • Sorry for OT.

    Thanks Dumble, the script works fine.

    Regards

    Tuesday, July 2, 2019 3:35 PM