不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起运行
<# :
echo off&cls
rem 将多张照片分别剪切/移动到以其拍摄日期命名的文件夹里
mode con lines=3000
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]::Default))) -Args '%~f0'"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
Add-Type -AssemblyName 'System.drawing';
function getdate($v){
$wt=$v.LastWriteTime.toString('yyyy-MM-dd').split('-');
$s=$wt[1]+'\'+($wt -join '');
$img=[System.Drawing.Image]::FromFile($v.FullName);
foreach($it in $img.PropertyItems){
if($it.Id -eq 0x9003){
$dt=[System.Text.Encoding]::ASCII.GetString($it.Value).split(' ');
$d=$dt[0].split(':');
$s=$d[1]+'\'+($d -join '');
};
};
return $s;
};
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
$files=@(dir -liter $path|?{('.jpg' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
for($i=0;$i -lt $files.length;$i++){
$newpath=getdate $files[$i];
$newfolder=$path+'\'+$newpath;
if(-not (test-path -liter $newfolder)){[void](md $newfolder);};
write-host ($files[$i].Name+' --> '+$newpath);
}
<# :
echo off&cls
rem 将多张照片分别剪切/移动到以其拍摄日期命名的文件夹里
mode con lines=3000
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]::Default))) -Args '%~f0'"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
Add-Type -AssemblyName 'System.drawing';
function getdate($v){
$wt=$v.LastWriteTime.toString('yyyy-MM-dd').split('-');
$s=$wt[1]+'\'+($wt -join '');
$img=[System.Drawing.Image]::FromFile($v.FullName);
foreach($it in $img.PropertyItems){
if($it.Id -eq 0x9003){
$dt=[System.Text.Encoding]::ASCII.GetString($it.Value).split(' ');
$d=$dt[0].split(':');
$s=$d[1]+'\'+($d -join '');
};
};
return $s;
};
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
$files=@(dir -liter $path|?{('.jpg' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])});
for($i=0;$i -lt $files.length;$i++){
$newpath=getdate $files[$i];
$newfolder=$path+'\'+$newpath;
if(-not (test-path -liter $newfolder)){[void](md $newfolder);};
write-host ($files[$i].Name+' --> '+$newpath);
}

