Rom Organization Scripts


sparr

Member
Joined
Jun 3, 2006
Messages
292
Two handy pieces of bash magic that help me organize my ROM collections, I hope they are helpful to the rest of you.

First, a single line to put all your roms in individual zip files:
Code:
for i in *; do zip $i.zip $i; done

And second, a longer script that will change this:
aaa.rom
aab.rom
bbb.rom
into this:
A/aaa.rom
A/aab.rom
B/bbb.rom
All/aaa.rom -> ../A/aaa.rom
All/aab.rom -> ../A/aab.rom
All/bbb.rom -> ../B/bbb.rom

This makes roms easier to look through in emulators that can handle multiple rom folders, as well as safer for emulators that crash on really (10k+) long directories. The symlinks in All/ are useful for emulators that can only handle one rom folder.

Code:
#!/bin/sh
mkdir All
rm All/*
for i in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
do
  mkdir $i
  for j in $i*
  do
	mv "$j" $i
  done
  for j in $(echo $i | tr A-Z a-z)*
  do
	mv "$j" $i
  done
  cd $i
  for j in *
  do
	ln -s "../$i/$j" "../All/$j"
  done
  cd ..
  rmdir $i
done

mkdir 0
for i in 0 1 2 3 4 5 6 7 8 9
do
  for j in $i*
  do
	mv "$j" 0
  done
done
cd 0
for j in *
do
  ln -s "../0/$j" "../All/$j"
done
cd ..
rmdir 0
 
Back
Top