none
Copy multiple file to multiple dir if file name contain string RRS feed

  • Вопрос

  • Hello!

    I have a folder with (~200) files. I need to copy them 1 by 1 to specified paths based on a "name" the files contain.

    My problem: How do i pair the names with the paths?

    $file1 = “C:\_privat\filecopy\Name.txt”
    $file2 = “C:\_privat\filecopy\Paths.txt”
    $files = Get-ChildItem "C:\ThisFolder\"
    $names = Get-Content $file1
    $paths = Get-Content $file2
    $cont = 0
    foreach ($file in $files)
    {
      foreach ($name in $names)
        {
         If ($file -contain $name)
          Then copy to $path
        }
    }

    But i have no idea how to do this.

    I know witch path to take because the name was originally next to the path in the txt.

    Any help appreciated.


    I Hate Mondays

    19 июня 2019 г. 9:14

Все ответы