Skip to content

Instantly share code, notes, and snippets.

@gingerbeardman
Last active Dec 2, 2021
Embed
What would you like to do?
Shell script to generate directory listings of old HFS CD-ROMs using my fork of hfsutils/hls and my convert2unicode.tcl script
#!/usr/bin/env zsh
autoload colors; colors
cd "~/Documents/CD-ROMs"
rm *.txt
catalogue() {
while read -r iso; do
directory=$(dirname "$iso")
fullname=$(basename -- "$iso")
filename="${fullname%.*}"
txt="$filename.txt"
echo -n "$fg_bold[green]$filename$reset_color "
hmount "$iso" 1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
hmount "$iso" > /dev/null 2>&1
fi
hvolinfo=$(hvol)
title=$(echo $hvolinfo | grep "Volume name is" | awk -F\" '{print $2}')
echo $title
hls -p > "$filename.txt"
datestamp=$(echo $hvolinfo | grep created | sed -e 's/Volume was created on //g')
touchstamp=$(date -jf "%a %b %e %H:%M:%S %Y" "$datestamp" +"%Y%m%d%H%M.%S")
touch -t $touchstamp "$filename.txt"
humount
done
}
find "/Volumes/320GB/Macintosh/Japanese/" -type f -iname '*.ISO' -o -iname '*.DSK' ! -name '.*' | catalogue
echo ""
echo "$fg_bold[green]Converting to UTF-8$reset_color using Tcl"
wait
./convert2unicode.tcl -encoding macJapan *.txt
# ./convert2unicode.tcl -encoding japanese *.txt
echo ""
echo "$fg_bold[green]Analysing$reset_color using uchardet"
wait
uchardet *.txt | rg --invert-match ": (UTF-8|ASCII)" > _uchardet.text
xattr-2.7 -wx com.apple.FinderInfo "0000000000000000000C00000000000000000000000000000000000000000000" _uchardet.text
[ -s _uchardet.text ] || rm _uchardet.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment