bat改名求助
bat吧
全部回复
仅看楼主
level 1
p訁 楼主
partition_index: SYS1
partition_name: pgpt
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0x0
physical_start_addr: 0x0
partition_size: 0x8000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: INVISIBLE
is_upgradable: false
empty_boot_needed: false
reserve: 0x00
- partition_index: SYS2
partition_name: boot_para
file_name: NONE
is_download: false
type: NORMAL_ROM
linear_start_addr: 0x8000
physical_start_addr: 0x8000
partition_size: 0x100000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: INVISIBLE
is_upgradable: false
empty_boot_needed: false
reserve: 0x00
- partition_index: SYS3
partition_name: recovery
file_name: recovery.img
is_download: true
type: NORMAL_ROM
linear_start_addr: 0x108000
physical_start_addr: 0x108000
partition_size: 0x2000000
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: UPDATE
is_upgradable: true
empty_boot_needed: false
reserve: 0x00
读取 file_name: 比如有个ROM3的文件 需要自动从这个文档里面读取SYS3下的file_name: 并且改名成file_name:读取的name
2021年03月27日 12点03分 1
level 9
不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行
<# :
echo off&cls
rem 从文本文件内读取/提取特征/特定字符串中的部分内容来重命名该文件
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312')))) -Args '%~f0'"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
$newfolder="#result";
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
if(-not (test-path -liter $newfolder)){[void](md $newfolder);};
$newfolder=get-item -liter $newfolder;
$files=@(dir -liter $path|?{($self.Name -ne $_.Name) -and ($_ -is [System.IO.FileInfo])});
if($files.length -ge 1){
write-host $files[0].Name;
$enc=New-Object System.Text.UTF8Encoding $False;
$text=[IO.File]::ReadAllText($files[0].FullName,$enc);
$m=[regex]::match($text,'partition_index ?: ?SYS3\s+[\s\S]*?file_name ?: ?(.+)');
if($m.success){
write-host $m.groups[1].value;
}
}
2021年03月28日 17点03分 2
1