tus*_*ath 25 powershell copy-item
我正在使用PowerShell Copy-Item命令将包含文件的目录复制到另一个位置.
我想显示控制台上被复制的所有文件,以便我知道复制命令的状态.
Jac*_*kie 34
如果您只想在控制台中看到它,请使用-verbose开关:
copy-item -path $from -destination $to -verbose
Run Code Online (Sandbox Code Playgroud)
如果要获取文件或目录列表:
$files = copy-item -path $from -destination $to -passthru | ?{$_ -is [system.io.fileinfo]}
Run Code Online (Sandbox Code Playgroud)
$source=ls c:\temp *.*
$i=1
$source| %{
[int]$percent = $i / $source.count * 100
Write-Progress -Activity "Copying ... ($percent %)" -status $_ -PercentComplete $percent -verbose
copy $_.fullName -Destination c:\test
$i++
}
Run Code Online (Sandbox Code Playgroud)