2016-09-09 80 views
1

我使用2个脚本通过文件夹内的年份torrent文件进行重新排版,但每个脚本都不完整,因为我必须同时使用它们来移动它们。将文件夹移动到文件夹中移动

例如

1脚本

@Echo Off 
For %%a In (*19???.torrent *20???.torrent) Do Call :Sub "%%~a" 
Exit/B 
:Sub 
Set "mfn=%~n1" 
Set "lfc=%mfn:~-5% 
Set "lfc=%lfc:(= %" 
Set "lfc=%lfc:)= %" 
Set "lfc=%lfc: =%" 
If Not Exist "%lfc%\" MD %lfc% 
Move %1 %lfc% 

不要动文件,如(文件扩展名的.torrent)

Animali Pazzi (1939) Toto 
Anno 2000 La Corsa Della Morte 
American History X 1998 1080p ENG 
Devil 2010_001 

第二脚本

@Echo Off 
For /F "Tokens=*" %%a In (
    'Dir/B/A-D *.torrent^|Findstr/R "\<19[0-9][0-9]\> \<20[0-1][0-9]\>"') Do (
    For %%b In (%%~na) Do Call :Sub "%%a" "%%b") 
Pause 
Exit/B 
:Sub 
Set "mfn=%~2" 
Set "mfn=%mfn:(=%" 
If %mfn:)=% GEq 1900 (If %mfn:)=% Lss 2017 (If Not Exist "%mfn:)=%\" MD %mfn:)=% 
     Move %1 %mfn:)=%)) 

不移动文件,如

Alla 39 Eclisse - The Awakening 1980_001 
Predators 2010_002 
Sono il Numero Quattro.2011_001 
Abbronzatissimi.1991.avi 
Continuavano a chiamarlo trinita1971 x264 
32.Dicembre.1988.avi 

我想这两个脚本,解决这个问题,移动的融合。

+0

您可以用[这](http://stackoverflow.com/a/39345515/2861476)试试。 –

+0

该解决方案正确创建文件夹,不会移动文件。我尝试添加我的代码,但出现错误 –

+0

它在答案中显示。出于调试目的,'move'命令前缀有一个'echo'。如果输出到控制台是正确的,则移除'echo'离开'move'。 –

回答

1

我建议一个不同的脚本方法,如PowerShell的:

$ToFolder = "$env:USERPROFILE\Desktop\to" 
$FromFolder = "$env:USERPROFILE\Desktop\From" 

#Create the sample folder on your desktop 
#This line can be commented out if your ToFolder exists 
New-Item $ToFolder -ItemType directory -Force 

GCI -Path $FromFolder *.torrent | % { 
    if ($_.Name -match "(19|20)\d{2}") { 

     #Check to see if year folder already exists at the destination 
     #If not then create a folder based on this year 
     if (!(Test-Path "$ToFolder\$($Matches[0])")) { 
      New-Item -Path "$ToFolder\$($Matches[0])" -ItemType directory 
     } 

     #Transfer the matching file to its new folder 
     #Can be changed to Move-Item if happy with the results 
     Copy-Item -Path $_.FullName -Destination "$ToFolder\$($Matches[0])" -Force 
    } 
} 
+0

您的解决方案非常棒。我用'Move-Item'替换'Copy-Item' –

相关问题