Batch Processing Details

How to use Powershell to do batch Processing
Some details below:

[int]$sequenceNum = 25
[int]$methodNum = 3

$strPathBasketball = "E:\ErrorConcealment\Sequence\sequence_copy_yuv_Basketball\"
$strConfig = "E:\ErrorConcealment\Sequence\decoder_tmp.cfg"

$strInputFile = "InputFile              = 'D:\CY\JM18.6_RC\sequence_copy_yuv_Basketball\Basketball_1920x1080_frame2_confirm.264'"

$files = Get-Childitem E:\ErrorConcealment\Sequence\sequence -Recurse -Include *.264

<#
foreach ($file in $files)   #遍历文件
{
    Write-Host $file.PSPath

}
#>
$execPath = "D:/CY/JM18.6_RC/jm18.6/build/vs13-x86_64/Debug/jm.exe"

$a = "decoder_tmp.cfg"
$beginEnd = 0
$endNum = 75
$s1 = "-d"
$s2 = "-b"
$s3 = "-e"
#param($a, $beginEnd,$endNum)
$execArgs = "-d"
$execArgs = $execArgs + "decoder_tmp.cfg"
$execArgs = $execArgs +  "-b"
$execArgs = $execArgs + [int]0
#$execArgs = $execArgs + "-e"
$execArgs = $execArgs + [int]75
#$execArgs = $execArgs + "-e 75"
$execArgs.Split()
if(Test-Path $execPath)
{
    Write-Host "Success"
   cd "D:/CY/JM18.6_RC/jm18.6/build/vs13-x86_64/Debug"
   #& $execPath $execArgs.Split() 
   #& $execPath -argumentlist 
   Start-Process -FilePath jm.exe -ArgumentList "-d decoder_tmp.cfg -b 0 -e 75" 
   # .\ $execPath
    #$execPath
    Write-Host "S"
}
$execArgs = ""
#dir F:\Code_Practice\Temporal_TEST\Debug
#cmd /c $execPath


<#
for($i = 1; $i -le $sequenceNum; $i++)
{
    for($j = 1; $j -le $methodNum; $j++)
    {
        if(( $i -eq 2) -and ($j -eq 2 ))
        {
            $strOP = $strPathBasketball + $i + "_sequence_" + $j + ".yuv"
            #Write-Host $strOP
            $file = Get-Content $strConfig
            #Write-Host $file

            $reg = "(InputFile)(?<alp>[\s\S]*?)(.264)"
            #$reg = "([\s\S]*)"
            Clear-Content $strConfig
            foreach($line in $file){
                #Write-Host $line
                if($line -match $reg){
                    $line = $line.Replace($Matches.alp,"success");
                    Add-Content $strConfig -Value $line         
                    Write-Host "Success";
                    write-host $Matches.alp;

                }
                else{
                    Add-Content $strConfig -Value $line 
                }
            }
        } 
    }
}
#>
$execPath="D:\Progra~1\FlashFXP\flashfxp.exe"
$execArgs="-upload ftp://u:p@ip:21 "
$execArgs=$execArgs+"-remotepath=`"/`" "
$execArgs=$execArgs+"-localpath=`"d:\123\`" "
& $execPath $execArgs.Split()
$file = Get-Content "d:\1.txt"
$reg = "\d+(?<alp>\w+?)\d+"
foreach($line in $file){
   if($line -match $reg){        
       $Matches.alp;
   }
}
$files = Get-Childitem E:\test -Recurse -Include *.xml
foreach ($file in $files)
{
    $content = get-content $file.pspath
    $content
}
foreach ($line in $content)
   {
       $liner = $line.Replace("nihao","Hello")
   } 
foreach ($line in $content)
{
   $liner = $line.Replace("nihao","Hello")
   Set-Content $file.pspath -Value $liner
}

copy-item E:\test  F:\ -force -recurse  
$files = Get-Childitem E:\test -Recurse -Include *.xml
foreach ($file in $files)   
{
 $content = get-content $file.pspath
  clear-content $file.pspath  
   foreach ($line in $content) 
   {
       $liner = $line.Replace("nihao","Hello")
       Add-content $file.pspath -Value $liner 
   }
}   
# http://www.cnblogs.com/dreamer-fish/archive/2013/01/09/2852935.html
Test-Path D:\q.txt
Test-Path C:\Scripts\Archive -pathType container
Test-Path "HKCU:\Software\Microsoft\Driver Signing"
Test-Path Alias:\gci
Test-Path Env:\username
Test-Path C:\Scripts\Archive -pathType leaf
Test-Path C:\Scripts\Archive\*.ps1
Test-Path C:\Scripts\Archive\* -include *.ps1, *.vbs
Test-Path C:\Scripts\Archive\* -include Test*.ps1, Test*.vbs
Test-Path C:\Scripts\Archive\* -exclude *.ps1
Test-Path C:\Scripts\Archive\* -exclude *.gif, *.jpg
Test-Path D:\网站备份\2013-04-*\cnsm* #检查2013-04开头的目录下有没有cnsm开头的项目
$fileList = Get-ChildItem “D:\MyProject\" -recurse *.cs | %{$_.FullName}
Foreach($file in $fileList)
{

   $tmpContent = Get-Content $file

  for ($i=0; $i -le $tmpContent.length; $i++)
  {
    if($tmpContent[$i] -like '*myString *') 
     {
      write-host $file
      write-host $tmpContent[$i] -background red
    }
   }
}

select-string 1.0.101 *.xaml 
# http://www.cnblogs.com/fdyang/archive/2013/01/29/2882122.html
# http://www.pstips.net/powershell-online-tutorials/#Powershell脚本
"Mr. Miller and Mrs. Meyer" -replace "(Mr.|Mrs.)", "Our client"

Parameter passing:
在编写PowerShell脚本的时候,可以通过给变量赋值的方法输出想要的结果,但这样的话,需要改动脚本内容。其实也可以在脚本中定义参数,然后再在执行脚本的时候对参数赋值,而无需改动脚本内容。
  在PowerShell脚本中,可以使用param()声明参数,如下:
  param( a, b)
  write-host “Hello, a  writehostnihao, b”
  将以上内容保存在F盘根目录下,命名为hello.ps1。
  在命令提示符下运行该脚本,并分别为参数 a b指定值为“Lily”和“Lucy”,方式如下:
  C:\Users\Administrator>powershell.exe F:\hello.ps1 Lily Lucy
  脚本执行结果为:
  Hello,Lily
  nihao,Lucy
  如果需要改变参数位置,需要为不同的参数指定值,如将 aLucy b指定值为“Lily”,方式如下:
  C:\Users\Administrator>powershell.exe F:\hello.ps1 -b Lily -a Lucy
  脚本执行结果为:
  Hello,Lucy
  nihao,Lily
  在声明参数的时候,还可以指定参数类型,如下:
  param([string] a,[int] b)
   a+ b
  在给脚本传递参数的时候,如果为 a b指定参数类型为string,则会报错,如下:
  C:\Users\Administrator>powershell.exe F:\hello.ps1 -a LiLei -b Lin
  F:\hello.ps1 : 无法处理对参数“b”的参数转换。无法将值“Lin”转换为类型“System.
  Int32”。错误:“输入字符串的格式不正确。”
  所在位置 行:1 字符: 25
  + F:\hello.ps1 -a LiLei -b <<<< Lin
  + CategoryInfo : InvalidData: (:) [hello.ps1], ParameterBindin…
  mationException
  + FullyQualifiedErrorId : ParameterArgumentTransformationError,hello.ps1
  只有为其赋予int类型值才可以,如下:
  C:\Users\Administrator>powershell.exe F:\hello.ps1 -a 5 -b 6
  11
key Point in argument passing 1
key Point in argument passing 2

Some Skills in Execution of EXE
click here for more detail exe skiils in ps

Some difficult symbols in regulations
as for “ using `”
http://blog.chinaunix.net/uid-9781829-id-1997782.html

Change Path to String

$strFilesList = Get-ChildItem “E:\ErrorConcealment\Sequence\Sequence_Bat" -Recurse -include *.264
foreach ($strFile in $strFilesList) 
{
    $strFile1 = $strFile.ToString()  + ".yuv"
}

How to deal with String
String Using Method

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值