Skip to content

Instantly share code, notes, and snippets.

@bryc
Last active December 10, 2016 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryc/46155c4bbc8e751eb728 to your computer and use it in GitHub Desktop.
Save bryc/46155c4bbc8e751eb728 to your computer and use it in GitHub Desktop.
Various CMD Batch, Powershell and Visual Basic Script files
' 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
:: 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"
:: 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"
ffmpeg.exe -i %1 -codec copy "%~n1_2.m4a"
ffmpeg.exe -i %1 -codec copy "%~n1.ogg"
@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 ..
$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')
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...")
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
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 -o ""%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s"""
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 --playlist-reverse -i -f bestaudio"
WshShell.Run(ProgStr & " " & UsrInput & "> test.txt")
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment