我也l贴一个,PowerShell 脚本- $str1 = 'BitsPerComponent 1/ColorSpace/DeviceGray';
- $str2 = 'ImageMask true/BitsPerComponent 1 ';
- $arr = [byte[]][char[]]$str2;
-
- if( ![IO.Directory]::Exists('.\new') ){ $null = md .\new; }
-
- forEach( $a In (dir *.pdf -File) ){
- $Bytes = [IO.File]::ReadAllBytes($a.FullName);
- $Count = $Bytes.Count - $arr.Count;
- for( $i=0; $i -lt $Count; $i++ ){
- $s = [Text.Encoding]::ASCii.GetString( $Bytes[$i..($i + $arr.Count - 1)] );
- if( $s -eq $str1 ){
- for( $j=0; $j -lt $arr.Count; $j++ ){ $Bytes[$i+$j] = $arr[$j]; }
- break;
- }
- }
- [IO.File]::WriteAllBytes( '.\new\' + $a.Name, $Bytes );
- }
- pause
复制代码
|