[opensuse] Help -script guru's
Could anybody provide me with a script that removes or replaces non compatible characters from file / directory names so that such files can be stored on a vfat filesystem? Thanks Phil -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Philip Burness wrote:
Could anybody provide me with a script that removes or replaces non compatible characters from file / directory names so that such files can be stored on a vfat filesystem?
<code> #! /usr/bin/env python # import os, sys, re def main(): try: dir = sys.argv[1] except IndexError: dir = raw_input("Search in which directory? ") os.chdir(dir) for filename in os.listdir(dir): if re.search(r'[/?<>\:*|"]',filename): print "Found file with illegal characters: %s\n" % filename newname = re.sub(r'[/?<>\:*|"]','_',filename) os.rename(filename, newname) print "Renamed file to: %s\n\n" % newname return if __name__ == '__main__': main() </code> -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday, 2008-12-31 at 08:26 -0000, Philip Burness wrote:
Could anybody provide me with a script that removes or replaces non compatible characters from file / directory names so that such files can be stored on a vfat filesystem?
You could also have a look at the mtools, if what you intend is copying files. Try "man mkmanifest". - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAklcBZkACgkQtTMYHG2NR9X1agCfX+prrEFUxlxo3XLCg4GqUHjD Mn8AoICYvorzvzSqz0y0NaLfAZFLXL2F =/Bo3 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
Carlos E. R.
-
Philip Burness
-
Theo van Werkhoven