Created
October 16, 2015 01:30
-
-
Save brycied00d/fd86b75c52d5af3f8ce1 to your computer and use it in GitHub Desktop.
Parse TRANS.TBL To Rename Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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