发布网友 发布时间:2022-04-23 22:51
共1个回答
热心网友 时间:2023-10-12 18:26
<# :
@echo off
mode con lines=1000
set #=有问题联系&set 。=Q&set/az=0x53b7e0b4
title %#% +%。%%。% %z%
set "rootpath=%~dp0"
if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
cd /d "%rootpath%"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
echo;%#% +%。%%。% %z%
pause
exit
#>
Add-Type -TypeDefinition @'
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;
}
}
'@;
$newfolder='提取';
if(-not (test-path -liter ($args[0]+'\'+$newfolder))){[void](md ($args[0]+'\'+$newfolder) -force)};
$folders=@(dir -liter $args[0]|?{($_.Name -ne $newfolder) -and ($_ -is [System.IO.DirectoryInfo])});
for($i=0;$i -lt $folders.Count;$i++){
$files=@(dir -liter $folders[$i].FullName|?{(@('.jpeg','.jpg','.png','.gif','.bmp') -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
if($files.count -ge 1){
$list=[ExpDir]::Sort($files);
$c=10;
if($list.Count -lt $c){$c=$list.Count};
for($j=0;$j -lt $c;$j++){
$firstfile=$folders[$i].FullName+'\'+$list[$j];
$newname=$list[$j];
write-host ($folders[$i].Name+'\'+$list[$j]+' --> '+$newfolder+'\'+$newname);
cp -liter $firstfile ($args[0]+'\'+$newfolder+'\'+$newname) -force;
}
};
}