一个好老好老的老程序员了。
全部博文(915)
分类: Windows平台
2013-02-22 17:21:12
#------------------------------------------------------------------------------
# Function:从拷贝文件,并显示进度
# Author :wangccsy@126.com
# Date :2013-02-21
#------------------------------------------------------------------------------
$yestoday=Get-Date((Get-Date).AddDays(-1)) -Format yyyy-MM-dd
$remoteIp=""
$pathcommon=$remoteIp + "\Build Output\" + $yestoday + "\ERP\Common"
$pathrecon=$remoteIp + "\Build Output\" + $yestoday + "\ERP\Core"
$files = Get-ChildItem $pathcommon
$files1 = Get-ChildItem $pathrecon
$files = $files + $files1
$count = $files.count
$counter = 1
$dest = Get-Content d:\.path
foreach($file in $files)
{
$status = "copy files {0} on {1}:{2}" -f $counter,$count,$file.Name
# $restpath=$file.fullname.replace($path,"")
if ($file.PSIsContainer -eq $true){
$dest_tmp = $dest+$restpath
$restpath=$file.FullName
Copy-Item $file.FullName $dest_tmp -Force
}
else
{
$restpath = $file.Directoryname
$restpath = $restpath.replace($pathcommon,"")
if (! $restpath.equals(""))
{
$restpath = $restpath.replace($pathrecon,"")
}
$dest_tmp = $dest+$restpath
Copy-Item $file.FullName $dest_tmp -Recurse -Force
}
$n="{0:P2}" -f $($counter/$count)
Write-Progress -Activity "$n completed " $status -PercentComplete ($counter / $count*100)
$counter++
}