2 # Awk script to convert filenames shortened down to 8.3
3 # back to their larger size.
5 # Works by looking at every filename and seeing if it's shortened
6 # 8.3 version exists, and if so then mv the short name to the long
9 # Usage: find . -type f -print | gawk -f ren2long.awk | sh -x [ 2> /dev/null ]
15 # Takes the whole path and converts the basename part to 8.3. If it
16 # changed in the process we emit a sh command to mv it if the shortened
19 function parse_path(p,P2,N,NEW) {
25 N = index(P2,"/") # Go until all / are parsed
28 NEW = NEW name83(substr(P2,1,N-1)) "/"; # More of the path
33 print "echo skipping " p
36 NEW = NEW name83(P2) # Append path and 8.3 name
39 print "if [ -f " NEW " ]; then echo ::rm " NEW " ; rm " NEW " ; fi"
43 print "if [ -f " NEW " ]; then echo ::mv " NEW " " p " ; mv " NEW " " p " ; fi"
48 # Converts the a single component part of a file name into 8.3 format
50 function name83(fname,P,B,E) {
51 P = index(fname,"."); # Find the extension
53 if (P == 0) { # No extension
54 B = substr(fname,1,8); # Just truncate at 8 chars
58 B = substr(fname, 1, P <= 8 ? P-1 : 8); # At most 8 chars in name
59 E = substr(fname, P+1, 3) # And 3 in extension
60 P = index(E, ".") # 2 dot problem
64 B = B "." E # Put name together
68 bad["krb5-types-aux.h"] = 1
69 bad["autoconf.h.in"] = 1
70 bad["conv_tkt_skey.c"] = 1
71 ##bad["makefile"] = 2 -- windows have legitimate files with this name
74 parse_path($1) # Do it