Useful Batch Files
This article is a cache of helpful .bat (Windows)/.sh (Linux bash shell) scripts. Save the scripts inside a file with the correct extension for your Operating System, and you can drop them into VGM folders to use as needed.
See also "Some useful scripts for making VGM packs", and Kaijuu, the Windows BAT File Butler.
How to Use This List
Except in special cases, each batch file listing starts with a brief description. Then you are shown two forms:
The Windows .bat version comes first.
The Linux (bash/compatible) .sh version comes next.
To use the .bat versions directly on the Windows command line without creating a file, they will need a simple change to run. Wherever there are two percent signs (%%) in the command, remove one of the two signs.
Article improvement is in progress, so sometimes only the Windows form will be listed.
A Note on Linux/bash
Linux distros require .sh scripts to be marked Executable before they will be allowed to run. You can turn this on in the Properties of the script using your file manager.
Some file managers will prompt you to do this automatically when you try to run scripts. GNOME Desktop Environment requires using "Run as a program" rather than double-clicking.
If, after all the above, the .sh file still doesn't work, add this line to the top of the script file:
#! /usr/bin/sh
all2txt
Convert all VGMs in a folder to text files.
for %%a in (*.vg?) do vgm2txt "%%a" 0 0 for a in *.vg? ; do vgm2txt "$a" 0 0 ; donefind_start_points
Like all2txt, but is more convenient when all you need is to find the beginning trims.
for %%a in (*.vg*) do vgm2txt "%%a" 0 0:03 for f in *.vg? ; do vgm2txt "$f" 0 0:03 ; donechange_system (and other quick vgm_tag changers)
If you commonly need to change only the System part of many VGM tags, you can make .bats like these examples. Any of the vgm_tag short names can be used.
for %%a in (*.vg*) do vgm_tag -System:SMD "%%a"
for %%f in (*.vg?) do vgm_tag -System:Arc "%%f"With simple changes, you can do the same for any field:
for %%f in (*.vg?) do vgm_tag -Creator:"Alex Kidd" "%%f"Here are bash forms of the above examples.
for a in *.vg* ; do vgm_tag -System:SMD "$a" ; done
for f in *.vg? ; do vgm_tag -System:Arc "$f" ; done
for f in *.vg? ; do vgm_tag -Creator:"Alex Kidd" "$f" ; doneopt
Use optvgm and then vgm_cmp on all trimmed VGMs; then, use gzip on all optimized VGMs.
for %%f in (*_trimmed.vgm) do optvgm "%%f" "%%~nf.vgz" & vgm_cmp "%%~nf.vgz" & gzip "%%~nf_optimized.vgm" & ren "%%~nf_optimized.vgm.gz" "%%~nf_optimized.vgz"wrapPackText
Currently bash only. Wraps the lines of any TXT files inside the current directory to the limit of 48 characters, and places the results into a wrap subdirectory.
mkdir -p wrap
for f in *.txt ; do fold -s -w 48 "$f" >> wrap/$(basename "$f") ; doneclean_names_and_get_stats
Usage assumptions:
- (Windows only)
vgm_namecan be reached. - The folder this is used in/on only contains VGMs meant to go in the playlist.
- (For best results) The folder is named with the correct name for the pack.
echo off
vgm_name
dir *.vg? /b /on > "playlist.m3u"
vgm_stat playlist.m3u > stats.txt
for %%* in (.) do move "playlist.m3u" "%%~n*.m3u"
pausemove: Used in a .bat file, it overwrites existing files rather than ignoring them. (You can't avoid this behavior using a single simple line.)The bash version is slightly more robust:
for f in *_*.vg? ; do mv -n --no-copy -v "$f" "$(echo $f | sed -e 's/_[^\.]*//')"; done
dir --quoting-style=literal *.vg? > "$(basename `pwd`).m3u"
vgm_stat "$(basename `pwd`).m3u" > stats.txt
echo "Press any key to continue."
readThis behaves more or less the same as the Windows version; sed, as used above, removes underscore suffixes the same way vgm_name does. If you would like more context for this version, use the man command in your terminal to pull up help pages for mv, sed, dir, and pwd.