-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretroarch-scan.sh
executable file
·52 lines (40 loc) · 1.35 KB
/
retroarch-scan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
## retroarch-scan.sh by Naomi Peori <[email protected]>
## Scan a folder of roms to generate a RetroArch compatible playlist.
IFS="
"
if [ ! $# -eq 2 ]; then
echo "Usage: ${0} <directory> <name>"
exit
fi
if [ -d "${1}" ]; then
## Open the playlist file.
exec 3>"${2}.lpl"
## Output the playlist header.
echo '{' >&3
echo ' "version": "1.0",' >&3
echo ' "items": [' >&3
## For each zip file...
for FILE in $(find "${1}" -type f | sort); do
if [ -f "${FILE}" ]; then
echo "${FILE}"
## Optain some metadata about the file.
FILENAME=$(basename "${FILE}")
CRC32=$(./crc32.py "${FILE}")
## Output the playlist entry.
echo ' {' >&3
echo ' "path": "'${FILE}'",' >&3
echo ' "label": "'${FILENAME%.*}'",' >&3
echo ' "core_path": "DETECT",' >&3
echo ' "core_name": "DETECT",' >&3
echo ' "crc32": "'${CRC32}'|crc",' >&3
echo ' "db_name": "'${2}'.lpl"' >&3
echo ' },' >&3
fi
done
## Output the playlist footer.
echo ' ]' >&3
echo '}' >&3
## Close the playlist file.
exec 3>&-
fi