Parse through a directory and identify and copy.move files to an archive folder RRS feed

  • Question

  • I have a dilemma and dont really have a clue how to solve this.

    I have been given the task to remove a list of files

    They are in a one parent directory C:\data1\data2

    however the files are individually located in numerous nested directories




    I receive the files names in a spreadsheet and copy the path to a holding file named removal.txt

    I tired using the following script to identify the files and populate them (this way i can produce to data owner for verification)

    Get-childItem -Path C:\data1\data2\* -Recurse -include(Get-Content "C:\data1\data2\removal.txt") -verbose |Out-File -filepath "C:\data1\data2\\utput.txt"

    when i run this query i dont get any output 

    however if i only insert the file names in the removal.txt i.e. 




    i get the output with the data required

    what do i need in order for this to work?

    Priyantha Perera

    • Moved by Bill_Stewart Friday, March 15, 2019 5:25 PM This is not "scripts on demand"
    Wednesday, January 9, 2019 11:05 PM

All replies

  • Simplify.

    $files = Get-Content C:\data1\data2\removal.txt
    Get-childItem -Path C:\data1\data2\* -Recurse -include $files


    Wednesday, January 9, 2019 11:28 PM