powershell 各种CMD Batch,Powershell和Visual Basic脚本文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 各种CMD Batch,Powershell和Visual Basic脚本文件相关的知识,希望对你有一定的参考价值。

UsrInput = InputBox("Enter URL:")

If IsEmpty(UsrInput) = False Then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    ProgStr = "youtube-dl --playlist-reverse -i -f bestaudio"
    WshShell.Run(ProgStr & " " & UsrInput & "> test.txt")
End If
UsrInput = InputBox("Enter URL:")

If IsEmpty(UsrInput) = False Then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    ProgStr = "youtube-dl -i -f bestaudio -o ""%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"""
    WshShell.Run(ProgStr & " " & UsrInput & "> test.txt")
End If
ProgStr = "youtube-dl.exe -i -f bestaudio"

Dim UsrInput
    UsrInput = InputBox("Enter URL:")

If IsEmpty(UsrInput) = False Then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run(ProgStr & " " & UsrInput)
End If
UsrInput = InputBox("Enter URL:")

If IsEmpty(UsrInput) = False Then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    ProgStr = "youtube-dl -i -f bestaudio"
    WshShell.Run(ProgStr & " " & UsrInput)
End If
import sys, time
f = open(sys.argv[1],"rb")
contents = f.read(112)
f.close()

fileid = contents[0:3].decode("utf-8")

if fileid != "GBS":
	print("Invalid file!")
	time.sleep(1)
	sys.exit("Bye!")


numsongs  = contents[4]
firstsong = contents[5]

title     = contents[0x10:0x10+32].decode("utf-8")
author    = contents[0x30:0x30+32].decode("utf-8")
copyright = contents[0x50:0x50+32].decode("utf-8")

print(
    "Title: " + title + "\n" +
    "Author: " + author + "\n" +
    "Copyright: " + copyright + "\n" +
    "Total subsongs: " + str(numsongs) + "\n"
)

input("Press the <ENTER> key to continue...")
import sys, time
f = open(sys.argv[1],"rb")
contents = f.read(112)
f.close()

fileid = contents[0:3].decode("utf-8")

if fileid != "GBS":
	print("Invalid file!")
	time.sleep(1)
	sys.exit("Bye!")


numsongs  = contents[4]
firstsong = contents[5]

title     = contents[0x10:0x10+32].decode("utf-8")
author    = contents[0x30:0x30+32].decode("utf-8")
copyright = contents[0x50:0x50+32].decode("utf-8")

print(
    "Title: " + title + "\n" +
    "Author: " + author + "\n" +
    "Copyright: " + copyright + "\n" +
    "Total subsongs: " + str(numsongs) + "\n"
)

input("Press the <ENTER> key to continue...")
@ECHO OFF
CD Sound Crate Gold

for /r %%X in (*.webm) do (
    ffmpeg.exe -i "%%X" -codec copy "R:\Tiny\a\test\%%~nX.opus"
)




CD ..
ffmpeg.exe -i %1 -codec copy "%~n1.ogg"
ffmpeg.exe -i %1 -codec copy "%~n1_2.m4a"
: Convert DASH M4A to Normal M4A
:: %1   = Argument 1, will be quoted file path of first input file
:: %~n1 = Expands %1 to just the file name
:: '-codec copy' is used to process the file faster

ffmpeg -i %1 -codec copy "%~n1_2.m4a"
: Convert input file to WAV
:: %1   = Argument 1, will be quoted file path of first input file
:: %~n1 = Expands %1 to just the file name

ffmpeg -i %1 "%~n1_2.wav"
' getFirstByte function
Function GetFirstByte(Filename)
    File = CreateObject("Scripting.FileSystemObject").OpenTextFile(Filename, 1).Read(1)
    GetFirstByte = Asc(File)
End Function

' Ensure Argument 1 is present
If WScript.Arguments.Count > 0 Then
    
    OpenedFile = WScript.Arguments(0)
    FirstByte = getFirstByte(OpenedFile)
    Output = "Not a N64 ROM"
    
    Select Case FirstByte
        Case 128
            Output = "Normal (Z64)"
        Case 55
            Output = "Byteswapped (V64)"
        Case 64
            Output = "Wordswapped (N64)"
    End Select
    MsgBox Output
End If
$Files = Get-ChildItem -Path ".\*.m3u"
$Total = $Files.count

$Text = ""
for ($i = 0; $i -lt $Total; $i++) {

    $Path = Get-Content $Files[$i]
    Write-Host $Path
    $Text += $Path + "`n"
}

$sw = New-Object System.IO.StreamWriter('test.txt')
$sw.Write($Text)
$sw.Close()

Write-Host -NoNewLine 'Execution ended. Press any key to quit...'
$void = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')

以上是关于powershell 各种CMD Batch,Powershell和Visual Basic脚本文件的主要内容,如果未能解决你的问题,请参考以下文章

CMD和win powershell有啥区别

Livy 在 120 秒内未找到带有标签 livy-batch-10-hg3po7kp 的 YARN 应用程序

解决win10shift+右键显示在此处打开powershell而不是命令窗口的问题

从 CSV/TXT 创建文件夹并将匹配列移动到 Powershell 或 Batch 中的新目录

powershell 使用PowerShell在SDL Web中创建管理员用户。使用Tridion CoreService模块(https://github.com/pkjaer/tridion-po

powershell 使用PowerShell在SDL Web中创建管理员用户。使用Tridion CoreService模块(https://github.com/pkjaer/tridion-po