From: Michael K. <mic...@pu...> - 2004-06-22 14:41:33
|
Hi List At my company the admins wanted to get rid of the 31 char limitation and the character-encoding hassles between netatalk 1.6 and samba 2.x. In order to do that we had to rename an incredible amount of files, and create valid filenames for windows machines. Here's what we did and the script to rename all the old files from atalk 1.6 and now we run samba 3 and netatalk 2 beta - stop netatalk 1.6 - follow the steps for DB migration on the netatalk migration faq. # cd /path/to/share/.AppleDB # db_dump -f cnid.dump cnid.db # db_dump -f didname.dump didname.db # /usr/local/netatalk2.0-beta1/bin/cnid2_create # rm __db.* log.* # rm *.db # db_load -f cnid2.dump cnid2.db - run rename script and check output: # /root/mac2winvalidutf8/mac2winvalidutf8.py -v -r . > /root/rename-test.log # /root/mac2winvalidutf8/mac2winvalidutf8.py -v -r --notest . > /root/rename-final.log - start netatalk 2 using options:mswindows to keep mac users from creating crazy filenames again now about my script (see attachment). functionality: # This program renames files from from illegal characters to legal ones. # It converts filenames from MAC-ROMAN encoding to UTF-8 encoding # It removes characters illegal for windows: */\?<>:|" # It removes whitespace from beginning and end of filenames # It removes dots from beginning and end of filenames # Filenames that would be truncated to a zero length string will be renamed to a quote from the Movie "Finding Nemo" e.g. filename ' ...' will become 'Shark bait, oo ha ha!' # it doesn't touch filenames that are already valid utf-8 (they don't exist theoretically, but if the script dies during execution it wont do any harm if it's run again over the same directory.) performance: It took 2m40s on a pentium2/350 512RAM (that's the testserver, no need to feel sorry for us ;-)) to rename the following: Depth of deepest directory tree: 17 Total # of Files processed: 89224 Total # of Directories processed: 17191 Total # of Files renamed: 3944 Total # of Directories renamed: 361 NOTE: The --notest option will warn you twice before it starts to actually rename the files. Please take that seriously and check the output of the test runs if the renames actually work as you expect - there exists NO UNDO except your backups! Especially check special characters, strange filenames (consisting only of dots or spaces - yes we had such files!) and whatever your crew of users normally does. I thought that script may be useful for others, and could be added to the contrib section of netatalk. Feel free to send suggestions or improvements for this script, where improvement means everything unless you want to see the script written in language X using feature Y - it's written in python and it's not object oriented, get over it. ;-) -- michael kefeder programmierer -------------------------------------------------------------- Publicis Networks Kettenbrückengasse 16 A-1040 Wien mobil: 0676/88 5 88 603 Tel:++43/1/588 09 603 www.publicis-networks.at |