Assign MyVariable 0
goto 0x0
{
assign m2 currentpos
move 32768
assign m3 currentpos
block m2 (m3-1)
copyintonewfile "d:\File+MyVariable+.bin"
Assign MyVariable (MyVariable+1)
}[8193]
// 输出统计信息
MessageBox "操作完成,共执行 {saveCount} 次保存"
删除包含 9C351D 的文件
# 设置要搜索的目录路径
$searchDirectory = "d:\11 "
# 要查找的十六进制值
$hexPattern = "9C351D"
# 递归获取目录下所有文件
Get-ChildItem -Path $searchDirectory -File -Recurse | ForEach-Object {
# 读取文件内容为字节数组
$fileBytes = [System.IO.File]::ReadAllBytes($_.FullName)
# 将字节数组转换为十六进制字符串
$hexString = -join ($fileBytes | ForEach-Object { $_.ToString("X2") })
# 检查是否包含目标十六进制模式
if ($hexString -match $hexPattern) {
try {
# 删除文件
Remove-Item -Path $_.FullName -Force
Write-Host "已删除文件: $($_.FullName)"
} catch {
Write-Host "无法删除文件: $($_.FullName) - $_"
}
}
}
合并文件
合并文件
# 获取当前目录下所有file+数字格式的文件并按自然数字排序
$files = Get-ChildItem -File | Where-Object { $_.Name -match '^file\d+' } |
Sort-Object { [int]($_.Name -replace 'file(\d+).*','$1') }
# 创建二进制输出文件
$outputPath = "d:\11\merged.bin"
$outputStream = [System.IO.File]::Create($outputPath)
try {
# 逐个读取并合并文件
foreach ($file in $files) {
Write-Host "正在合并: $($file.Name)"
$fileStream = [System.IO.File]::OpenRead($file.FullName)
$fileStream.CopyTo($outputStream)
$fileStream.Close()
}
} finally {
$outputStream.Close()
}
Write-Host "文件已成功合并到 $outputPath" -ForegroundColor Green