#
# Rename long windows filenames to their DOS 8.3 names.
# (c)2002 thomas.kindler@gmx.de, released under the GPL.
#
# This script should be run on the output of "dir /x",
# and generates a batch file, that does the actual
# renaming.
#
# example:
#  dir /x *.mp3 | awk -f dosname.awk >temp.bat
#
# please download the awk intepreter from
# http://cm.bell-labs.com/cm/cs/who/bwk/awk95.exe
#
# only rename files where the shortname contains a "~"
#
# 01.06.2002 thorsten.godau@gmx.de :
#
# Original skript by tk
#
# $4 ~ /\~/ { 
#            split($4, fn, ".")
#            print "ren", $4, fn[1] ".XXX"
#            print "ren", fn[1] ".XXX", fn[1] "." fn[2]
#           }
# 
# Skript modified.
# - In Win95/98, the 8.3-name is located in the
#   first two columns -> replaced all $4 with $1 (hint from tk)
# - In the DIR output, the extension of the 8.3-realname is
#   not separated with a dot. So fn[2] does not contain the
#   extension but $2 does -> split() discarded. Name is in $1
#   (col 1), the extension in $2 (col 2)

$1 ~ /\~/ { 
            print "ren", $1 "." $2, $1 ".XXX"
            print "ren", $1 ".XXX", $1 "." $2
          }
