差分
このページの2つのバージョン間の差分を表示します。
最新のリビジョン両方とも次のリビジョン | |||
python:拡張子の表記を統一 [2019/12/03 15:57] – 作成 baba | python:拡張子の表記を統一 [2019/12/03 15:58] – baba | ||
---|---|---|---|
行 1: | 行 1: | ||
====== ファイル拡張子の表記を統一 ====== | ====== ファイル拡張子の表記を統一 ====== | ||
+ | 同じjpgファイルでも,hoge.jpg, | ||
+ | <file .py unifyExtension.py> | ||
+ | # coding: utf-8 | ||
+ | # 拡張子の表記を統一するスクリプト | ||
+ | # How to use(指定ディレクトリ(path_to_dataset)から .JPGファイルを検索し,.jpgに置き換える) | ||
+ | # python path_to_dataset .JPG .jpg | ||
+ | # | ||
+ | import os | ||
+ | import sys | ||
+ | import glob | ||
+ | |||
+ | args = sys.argv[1: | ||
+ | files = (glob.glob(args[0]+'/ | ||
+ | extension = args[2] | ||
+ | for f in files: | ||
+ | ftitle, text = os.path.splitext(f) | ||
+ | os.rename(f, | ||
+ | print(f+" | ||
+ | </ |