Skip to content

Instantly share code, notes, and snippets.

@nanzono
Created June 30, 2017 02:36
Show Gist options
  • Save nanzono/67274d1a2ccb303ec249b4435db53ff3 to your computer and use it in GitHub Desktop.
Save nanzono/67274d1a2ccb303ec249b4435db53ff3 to your computer and use it in GitHub Desktop.
G Suiteのファイル名を変更
# 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