Ask The Experts

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

robh-at-work
3,827 Views
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\}

 
3 REPLIES 3

robh-at-work
3,720 Views

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.

robh-at-work
3,715 Views

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.

MStubbs
3,154 Views

while I can get date components to work fine, I can't access any time components for match.  I get name 'hour' is not defined etc..., I used modified and mtime...  Was trying to setup a precopy of data without running into a file being activiely written to.

 

xcp copy -match "mtime>1*hour" <source> <destination>

 

Error: Error evaluating expression "mtime>1*hour": name 'hour' is not defined.

 

Tried every varation of hour that I could think of as well.  Is there some fmt(iso(mtime)) required?

Public