Skip to content

Instantly share code, notes, and snippets.

@gusioo
Created April 26, 2016 19:57
Show Gist options
  • Save gusioo/75543bd1fc5b9eb791ac8485e0c1a325 to your computer and use it in GitHub Desktop.
Save gusioo/75543bd1fc5b9eb791ac8485e0c1a325 to your computer and use it in GitHub Desktop.
Rename folders in OneDrive
# -*- coding: utf-8 -*-
import os
basedir = "D:\OneDrive\Obrazy\Archiwum"
for directory in os.listdir(basedir):
new_dir = directory.split(" ")
if new_dir[:-3] != []:
old_name = os.path.join(basedir, directory)
new_name = os.path.join(basedir, " ".join(new_dir[:-3]))
os.rename(old_name, new_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment