#! /usr/bin/env python3
import sys, os
-from recode_filenames import _recode
-if len(sys.argv) == 3:
+from m_lib.defenc import default_encoding
+
+if len(sys.argv) == 1:
+ src_encoding = default_encoding
+ if src_encoding == 'utf-8':
+ sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0])
+ else:
+ dst_encoding = 'utf-8'
+ start_dir = '.'
+elif len(sys.argv) == 2:
+ src_encoding = default_encoding
+ dst_encoding = sys.argv[1]
start_dir = '.'
+elif len(sys.argv) == 3:
+ src_encoding = default_encoding
+ dst_encoding = sys.argv[1]
+ start_dir = sys.argv[2]
elif len(sys.argv) == 4:
+ src_encoding = sys.argv[1]
+ dst_encoding = sys.argv[2]
start_dir = sys.argv[3]
else:
- sys.exit("Usage: %s src_enc dst_enc [start_dir]" % sys.argv[0])
+ sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0])
+
+# Fake for recode_filenames.py
+sys.argv = ['', src_encoding, dst_encoding]
+from recode_filenames import _recode
def _onerror(exc):