Ask The Experts

how to use xcp -match options to only copy files from a given month of a given year

i am migrating a large number of small files (10 million) and the business unit wants them in sub-folders 201701, 201702, 201703..... currently there in 3 massive directories on several different servers with no folder structure. The file names do not have a disernalable pattern that could be used to sort them.
 
i am not a programmer so the -match options are a bit vague for me. All i need to see is an Example of setting up a date range.
 
xcp copy -match (files from 01 2017) \\restore1\source \\netapp\destination\201701
i found this for power shell

Get-ChildItem | Where-Object {$_.LastWriteTime -gt '10/1/18' -and $_.LastWriteTime -lt '11/1/18'} | foreach {Copy-Item -Path $_.filename -Destination .\201810\}

 
2 REPLIES 2

Re: how to use xcp -match options to only copy files from a given month of a given year

i received this from another source:

 

Ok, then you should try something like this:

xcp copy -match “created < 1*year” <source> <target>

xcp copy -match “modified < 1*year” <source> <target>

  • “*year” can be changed with any other period of time (hour, day, month, year)

The given examples can be combined to a single command to filter the files created and modified in the same time.

xcp copy -match “created < 1*year and modified < 1*year” <source> <target>

 

if you want to find more details about how to use the match filter please run “xcp help -match” command.

Re: how to use xcp -match options to only copy files from a given month of a given year

to all who read this:

yes i ran the xcp help -match command and after reading the help output i'm still didn't gain the knowledge to use what i read.

However the examples provided did give rise to,  2 more questions:

 

  1. what is value of the 1* in: xcp copy -match “created < 1*year”
  2. what needs to be changed to make this a correct -match statement?

    xcp copy –match “created  = 2017year and > 2month and < 3month” <source> <target>

looking for files created feb. 2017 and what if i was looking for feb 2015.

Forums