I have a bunch of files in a mercurial repository with question marks in the name. (They're dumps of web pages for testing a bunch of scripts that process web pages, so they're of the form foo.cgi?bar=3&foo=someargument. I noticed after untarring the archive on Windows (I had to move it from the Linux half of my laptop on a MicroSD card; don't ask.) that tar was choking on all of the filenames with ? marks.
You can fix that quite easily with a script like this. (You'll have to run it on a Linux machine or something else that doesn't fail on ? marks, of course.)
#!/usr/bin/pythonI would have done this in bash, but I couldn't figure out how to iterate over filenames with spaces in them.
import subprocess, os
names = subprocess.Popen(r"find . -name '*\?*'", shell=True, \
for name in names.split("\n"):
name = name.strip()
if not name:
os.system(r"hg mv '%s' '%s'" % (name, name.replace("?", "@")))