Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6513805
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: 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++
}

阅读(5749) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~