Skip to content

Instantly share code, notes, and snippets.

Last active June 17, 2021 15:04
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Quick python script to rename directories AND files (recursively) in SVN repositories that have spaces in them. So next time somebody checks in a file pile containing spaces, I run this, and commit. End of problem. Inspired by, which renames only immediate files, via os.rename(). Hope it helps someone…
import os
import sys
import time
import subprocess
def space2_(directory):
for filename in os.listdir(directory): # parse through file list in the current directory
#print "checking %s" % filename
if filename.find(".svn") >= 0:
if filename.find(" ") >= 0: # if a space is found
newfilename = filename.replace(" ","_") # convert spaces to underscores
args = (['svn','mv',filename, newfilename]) # rename the file via svn mv, shell=False)
filename = newfilename
if os.path.isdir(filename):
space2_('.') # parse through file list in the current directory
Copy link

Thank you so much for the script. It made one of my jobs easy, otherwise which it would have been a nightmare for me.

Copy link

You're welcome, and thank you for letting me know. That's what this free-software/sharing thing is all about. ☮️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment