Batch file 在文件夹中移动torrent修复在文件夹中移动

Batch file 在文件夹中移动torrent修复在文件夹中移动,batch-file,Batch File,我使用2个脚本来重新定义文件夹中的按年torrent文件,但每个脚本都不完整,因为我必须同时使用这两个脚本来移动它们 比如说 第一稿 不要移动类似(文件扩展名为.torrent)的文件 第二稿 我希望这两种脚本的融合能够解决这个移动问题。我建议使用不同的脚本方法,例如powershell: $ToFolder = "$env:USERPROFILE\Desktop\to" $FromFolder = "$env:USERPROFILE\Desktop\From" #Create the sam

我使用2个脚本来重新定义文件夹中的按年torrent文件,但每个脚本都不完整,因为我必须同时使用这两个脚本来移动它们

比如说

第一稿

不要移动类似(文件扩展名为.torrent)的文件

第二稿


我希望这两种脚本的融合能够解决这个移动问题。

我建议使用不同的脚本方法,例如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
    }
}

您可以尝试。该解决方案仅正确创建文件夹,而不移动文件。我试图添加我的代码,但有点不对劲,答案中指出了这一点。出于调试目的,
move
命令的前缀是
echo
。如果控制台的输出正确,请移除回声,留下移动。您的解决方案非常好。我将
复制项目
替换为
移动项目
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
$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
    }
}