Add downloader.ps1

This commit is contained in:
Yuuki Chan 2024-01-07 20:01:38 +09:00
parent fd4cee84e4
commit 347cb27a1e

38
downloader.ps1 Normal file
View file

@ -0,0 +1,38 @@
# Catbox Downloader Script by Yuuki
# © https://raiza.dev/ - 2024-20XX
Get-ChildItem "./" -Filter "y2k12-*.txt" |
Foreach-Object {
$index = 0
$fileNames = @()
$content = Get-Content $_.FullName
$links = ""
ForEach ($line in $($content -split "`r`n"))
{
If ($line.StartsWith("mv ")) {
$f = $line.Substring($line.IndexOf('y2k12-'))
$fileNames += $f
}
}
ForEach ($line in $($content -split "`r`n"))
{
If ($line.StartsWith("https://files.catbox.moe/"))
{
$f = $line.Substring($line.IndexOf(".moe/") + 5)
If ([System.IO.File]::Exists($fileNames[$index]))
{
Write-Host "File already downloaded."
}
Else
{
Write-Host "Downloading" $fileNames[$index] "(" $line ")"
Invoke-WebRequest -Uri $line -OutFile $fileNames[$index]
}
$index += 1
}
}
}