- <# :
- cls&echo off&cd /d "%~dp0"
- path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0;%path%
- set "current=%cd%"
- powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
- pause
- exit
- #>
- $current=($env:current).trimend('\');
- $folder1=$current+"\1";
- $folder2=$current+"\2";
- $output=$current+"\3";
- if(-not (test-path -literal $folder1)){write-host ('"'+$folder1+'" path error or not exist');exit;}
- if(-not (test-path -literal $folder2)){write-host ('"'+$folder2+'" path error or not exist');exit;}
- if(-not (test-path -literal $output)){[void][IO.Directory]::CreateDirectory($output);}
-
- $codes=@'
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- public static class ExpDir
- {
- [DllImport("Shlwapi.dll", CharSet=CharSet.Unicode)]
- public static extern int StrCmpLogicalW(string p1, string p2);
- public static string[] Sort(string[] f)
- {
- Array.Sort(f, StrCmpLogicalW);
- return f;
- }
- }
- '@;
- Add-Type -TypeDefinition $codes;
-
- $arr=@(dir -literal $folder1|?{('.bin' -ne $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- $brr=@(dir -literal $folder2|?{('.bin' -ne $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $arr.length;$i++){
- remove-item -literal $arr[$i].FullName -force -ErrorAction SilentlyContinue;
- }
- for($i=0;$i -lt $brr.length;$i++){
- remove-item -literal $brr[$i].FullName -force -ErrorAction SilentlyContinue;
- }
- $arr=@(dir -literal $folder1|?{('.bin' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
- $brr=@(dir -literal $folder2|?{('.bin' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
- if(($arr.length -ge 1) -and ($brr.length -ge 1)){
- $files1=[ExpDir]::Sort($arr);
- $files2=[ExpDir]::Sort($brr);
- for($i=0;$i -lt $files1.count;$i++){
- if($i -lt $files2.count){
- $f1=get-item -literal ($folder1+'\'+$files1[$i]) -force;
- $f2=get-item -literal ($folder2+'\'+$files2[$i]) -force;
- write-host $f1.FullName;
- write-host $f2.FullName;
- $b1=[IO.File]::ReadAllBytes($f1.FullName);
- $b2=[IO.File]::ReadAllBytes($f2.FullName);
- $nb=$b2+$b1;
- $newfile=$output+'\ALL_'+$f2.Name;
- [IO.File]::WriteAllBytes($newfile, $nb);
- remove-item -literal $f1.FullName -force -ErrorAction SilentlyContinue;
- remove-item -literal $f2.FullName -force -ErrorAction SilentlyContinue;
- break;
- }
- }
- }
复制代码
|