EDIT: It seems blogger *really* doesn't like double-chevrons and it tries to replace them with >> so if you see that, it's supposed to be a double-chevron instead (>>).
I wrote a couple of bash scripts that could be useful for people using RetroArch and figured I'd post them here.
I wrote a couple of bash scripts that could be useful for people using RetroArch and figured I'd post them here.
First off is a script for 'dumb' scanning and playlist generation. That is, it doesn't check against any databases, so it catches things like ROMhacks and translations that don't appear in the No-Intro database that we use for the built-in content scanning:
#!/bin/bashWhen you run the script from a terminal/CLI, it will ask you to enter the path to the core library used to launch the content you're scanning, the path to the directory to be scanned and a name for the playlist, then it'll scan through the specified directory for any files and add them to a new playlist.
COUNTER=1
echo "Enter the absolute path to your core"
read core
echo "Enter the absolute path to the directory you want to scan"
echo "(exclude trailing slashes)"
read content
echo "Enter the name of the playlist"
read name
for i in $content/*; do
echo "$i" >> $name
echo "$i" | sed 's=.*/==' >> $name
echo "$core" >> $name
echo "$core" | sed 's=.*/==' >> $name
echo "$COUNTER|crc" >> $name
echo "" >> $name
done
Askot, a user from the RetroArch forums, made a variation in which you pass the variables directly at launch time instead of answering questions:
#!/bin/bashIt also removes the file extension from the playlist entries, which some people may prefer (e.g., Tetris instead of Tetris.nes). You would use it like this:
COUNTER=1
for i in $2/*; do
echo "$i" >> $3
echo $i | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$1" >> $3
echo "$1" | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$COUNTER|crc" >> $3
echo "" >> $3
COUNTER=$[$COUNTER +1]
done
./dumbscan /path/to/core.so /path/to/content /path/to/playlist.lpl
Reader Unknown commented that the above script(s) can fail on files with spaces in the names and will leave dupes if you scan the same directory multiple times. This version should alleviate those issues:
#!/bin/bashThe next script generates basic cue sheets for disc image files that don't have them already, like iso and img. This will make (most of) them usable with the Mednafen/Beetle-PSX core.
COUNTER=1
SAVEIFS=$IFS
IFS=$'\n'
if [ -f $3 ]
then
rm $3
fi
for I in $2/*
do
echo "${I}" >> $3
echo ${I} | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$1" >> $3
echo "$1" | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$COUNTER|crc" >> $3
echo "DETECT" >> $3
COUNTER=$[$COUNTER +1]
done
IFS=$SAVEIFS
#!/bin/bashYou would use it like this:
longname=`echo "$@" | sed 's=.*/=='`
name=`echo "$@" | sed 's/\.[^.]*$//' | sed 's/.*\///'`
if [ -e "$name".cue ]
then
echo "Cue sheet \"$name.cue\" already exists. Aborting."
else
echo "FILE \"$longname\" BINARY" >> "$name".cue
echo "TRACK 01 MODE1/2352" >> "$name".cue
echo "INDEX 01 00:00:00" >> "$name".cue
fi
./cuemaker whatever.iso
2 comments:
The second script above has some issues. First if the file names have spaces in them this will fail. Second, it always simply appended to an existing playlist so there could be dups if you scanned again to the same file. Here is an edit with these issues solved:
#!/bin/bash
COUNTER=1
SAVEIFS=$IFS
IFS=$'\n'
if [ -f $3 ]
then
rm $3
fi
for I in $2/*
do
echo "${I}" >> $3
echo ${I} | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$1" >> $3
echo "$1" | sed 's/\.[^.]*$//' | sed 's/.*\///' >> $3
echo "$COUNTER|crc" >> $3
echo "DETECT" >> $3
COUNTER=$[$COUNTER +1]
done
IFS=$SAVEIFS
Hope this helps.
@Unknown
hey, thanks! I updated the post with your version :)
Post a Comment