Created
June 30, 2017 02:36
-
-
Save nanzono/67274d1a2ccb303ec249b4435db53ff3 to your computer and use it in GitHub Desktop.
G Suiteのファイル名を変更
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# conding: utf-8 | |
import os | |
import os.path | |
target_path = '/path/to/rename/ | |
def main(): | |
cnt = 0 | |
for dpath,dnames,fnames in os.walk(target_path): | |
for fname in fnames: | |
if fname == ".DS_Store": | |
continue | |
root, ext = os.path.splitext(fname) | |
print(root,ext) | |
if ext in ['.gslides', '.gsheet', '.gmap', '.gdoc']: | |
file_path_src = os.path.join(dpath, fname) | |
file_path_dst = os.path.join(dpath, root + ".txt") | |
os.rename(file_path_src, file_path_dst) | |
print(file_path_src) | |
cnt += 1 | |
print(cnt) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment