本帖最后由 idwma 于 2022-1-22 00:13 编辑
回复 24# 5i365 - #@&cls&powershell -version 2.0 "type '%~0'|out-string|iex"&pause&exit
- #$r='^(\d+).*' #1
- $r='^\D+(\d+)\D' #2
- #$r='\D+(\d+)$' #3
-
- $a=@{}
- $f=gc 歌单.csv -Encoding UTF8
- $f|%{
- $z=$_ -replace '^(\d+).*','$1'
- if (!($a.ContainsKey($z))){$a.$z=$_}
- }
- $d=@{}
- dir ".\任务" -recu * -inc *原唱*.txt,*伴奏*.txt,*歌词*.txt|%{
- if($_ -match '(原唱|伴奏|歌词)'){$c=$($_.fullname -replace '^.*?([^\\]*)\\[^\\]*$','$1')+'_'+$Matches[0]}
- foreach($i in gc $_){
- if($i -match $r){
- $z=$matches[1]
- if($a.ContainsKey($z)){$d[$c]+=@($a.$z)}
- }
- }
- }
- $d.keys|%{sc -Encoding UTF8 $($_+'.csv') ($f[0],($d.$_|sort{[int]($_ -split ',')[0]}))}
复制代码
|