country,year,last modified date as parameter to exclude the files

This topic contains 0 replies, has 1 voice, and was last updated by  s 3 weeks, 2 days ago.

  • Author
    Posts
  • #103309

    s
    Participant

    I am moving the files which is less than last modified date file to the Archive folder but i wanted to put parameter and not to move the files to archive which country wise max year and max modified date for an example

    file1_itlay_2017.xlsx last modified date is 26/6/2018 10:24 AM

    file1_itlay_2018.xlsx last modified date is 26/6/2018 10:24 AM

    so, in this case, it will take both the files because country wise & year wise max modified date to be taken

    in the below-mentioned query, I can only able to filter based on max modified date

    $sourcedir = 'C:\Users\garang\Documents\input_files\Advisory_rate'
    $destdir = 'C:\Users\garang\Documents\input_files\Advisory_rate\Archive'

    Get-ChildItem -File -Path $sourcedir |
    Sort-Object -Property LastWriteTime -Descending |
    Select-Object -Skip 1 |
    Move-Item -Destination $destdir -force

    1)This code is very much working for excluding or skipping last modified file from the folder—————————-2) the requirement is to exclude country & Year & last modified date file from folder and remaining to move to archive—————3) example says if in the file name like file1_itlay_2018.xlsx Italy as country comes for 2 times or more than that then year wise last modified dates should come on that particular year..so country, year, last modified date as parameter to exclude the files

You must be logged in to reply to this topic.