不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI/GB2312,将多个文件拖放到bat文件图标上运行<# :
cls&echo off&cd /d "%~dp0"&set "self=%~f0"&mode con lines=5000
rem 在多个文件名称开头添加修改日期的前缀字符
>nul chcp 65001
set "tmpfile=%tmp%\t.t"
setlocal enabledelayedexpansion
>"%tmpfile%" echo;!cmdcmdline!
endlocal
>nul chcp 936
set #=Any questions&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
$b=[Convert]::FromBase64String("IC0tPiA=");
$c=[Text.Encoding]::Default.GetString($b);
$self=get-item -literal $env:self;
$tmpfile=$env:tmpfile;
$enc=[Text.Encoding]::GetEncoding('UTF-8');
$text=[IO.File]::ReadAllText($tmpfile, $enc);
$text=$text -replace '^.+?\.(bat|cmd)','';
$text=$text.replace('"','').trim() -replace ' (?=[a-z]:)',"`n";
if($text -ne ''){
$files=$text -split '[\r\n]+';
for($i=0;$i -lt $files.length;$i++){
if([System.IO.File]::Exists($files[$i])){
$f=get-item -literal $files[$i] -force;
$prefix=$f.LastWriteTime.toString('yyyyMMdd#');
$f.FullName+$c+$prefix+$f.Name;
}
}
}else{write-host 'Drag and drop multiple files onto the bat file icon';}
追问大神你好,我试了你的方法,好像不行。就是窗口都说了要改成什么,但是实际上并没有改。烦请帮忙瞅瞅呢。