eucKR로 사용할때 만들어진 파일과 디렉토리의 한글이름이 죄다깨지는데 이걸 모두 UTF-8로변경할수는 없나요?
전 이런 스크립트를 사용합니다.
#!/usr/bin/python # -*- coding: utf-8 -*- import sys, os, shutil enc_from = 'utf-8' enc_to = 'uhc' def convert_dir(dir): if dir[-1] != '/': dir += '/' try: f_list = os.listdir(dir) except OSError, (errno, errstr): if errno == 13: print "오류: %s: 권한이 없습니다." % dir return False else: raise res = True for file in f_list: path = dir + file try: file_converted = file.decode(enc_from).encode(enc_to) path_converted = dir + file_converted except Exception: print "오류: %s: 파일명이 이미 %s 인코딩이거나 %s 인코딩이 아닙니다." % (path, enc_to, enc_from) else: if file != file_converted: shutil.move(dir + file, dir + file_converted) print "성공: %s: 변환되었습니다." % path_converted file = file_converted # 주의: 기존 변수를 바꿨음 else: print "오류: %s: 파일명이 이미 %s 인코딩입니다." % (path, enc_to) if os.path.isdir(dir + file): if not convert_dir(dir + file + "/"): res = False return res if len(sys.argv) != 2: if len(sys.argv) == 1: dir = "./" else: print "인자가 잘못되었습니다." sys.exit() else: dir = sys.argv[1] res = convert_dir(dir) if not res: print "진행 도중 일부 오류가 발생하였습니다."
----블로그 / 위키 / 리눅스 스크린샷 갤러리
팁에도 올려주세요!
추천한방!!! :D :D :D
..
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
전 이런 스크립트를 사용합니다.[code:1]#!/usr/bin/py
전 이런 스크립트를 사용합니다.
----
블로그 / 위키 / 리눅스 스크린샷 갤러리
아니!
팁에도 올려주세요!
추천한방!!! :D :D :D
추천한방!!! :D :D :D
..
댓글 달기