Skip to content

Instantly share code, notes, and snippets.

@brycied00d
Created October 16, 2015 01:30
Show Gist options
  • Save brycied00d/fd86b75c52d5af3f8ce1 to your computer and use it in GitHub Desktop.
Save brycied00d/fd86b75c52d5af3f8ce1 to your computer and use it in GitHub Desktop.
Parse TRANS.TBL To Rename Files
#!/bin/sh
# This is a little scriptlet I wrote to take the files I'd copied from a CD under
# Windows, which inexplicably did not honour the RockRidge or Joliet extensions,
# and rename them back to their correct names, and recreate symbolic links.
# Adjust as necessary (eg: some BSDs don't support -v on mv and ln)
#
# Bryce Chidester <[email protected]>
#
for DIR in $(find . -type d); do
(cd "$DIR" &&
(pwd
while read TYPE ISONAME REALNAME OPTLINK ; do
[ -e "$ISONAME" ] || (echo Skipping non-existent "$ISONAME" ; break)
[ -e "$REALNAME" ] || mv -v "$ISONAME" "$REALNAME"
[ "$TYPE" = "L" ] && ln -vsf "$OPTLINK" "$REALNAME"
done <TRANS.TBL
)
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment