1

我在共享上有一个目录,每个文件名的前缀都必须移动到特定目录。-filter 命令用于移动文件,但最好使用数组的值。任何帮助将不胜感激。

$source ="\\127.0.0.1\share\"

$File_Array_8HP70=@("108701")
$File_Array_8HP70X=@("108702")
$File_Array_9HP48=@("109401", "1094080", "1094090")
$File_Array_9HP48X=@("109402", "1094091", "1094082", "1094092")

$destination="\\127.0.0.1\TestFolder1\$DTS"
         $destination1="\\127.0.0.1\TestFolder2\$DTS"
         $destination2="\\127.0.0.1\TestFolde3\$DTS"

         $destination_array=@("$destination", "$destination1", "$destination2")

# filter works below - need to use array


         #$files = get-childitem $source -filter "108701*" -recurse
         #foreach ($file in $files)
         #{move-item $file.fullname $destination_array[0] -force}

         $files = gci $source |select-object -equals $file_array_8HP70
         foreach ($file in $files)
         {move-item $file.name is $($file_array_8hp70.name) $destination_array[0] -force}
4

1 回答 1

0

如果你写:

$source ="\\127.0.0.1\share\*"
$File_Array_8HP70_start = $File_Array_8HP70 | % {$_+"*"}
$files = get-childitem $source -include $File_Array_8HP70_start -recurse

它应该有帮助。

于 2012-11-06T12:52:17.797 回答