How to move a file with a complicated filename in python
<p>I am trying to do <code>$ mv &lt;file&gt; ..</code> in a python script using <code>subprocess.call()</code>. I am able to do this on 'normal' filenames, but on certain filenames it does not work. I do not have control of the filenames that are given to the script. Here is an example:</p>

<p>M filename is <code>"ITunes ES Film Metadata_10_LaunchTitles(4th Batch)_08_20_2010.XLS"</code></p>

<p>When I try and do the command directly into the python prompt and drag the file into it, this is what I get:</p>

<pre><code>&gt;&gt;&gt; /Users/David/Desktop/itunes_finalize/TheInventionOfLying_CSP/
    ITunes\ ES\ Film\ Metadata_10_LaunchTitles\(4th\ Batch\)_08_20_2010.XLS

No such file or directory
</code></pre>

<p>How would I go about moving this file in a python script?</p>

<p><strong>Update:</strong></p>

<p>Thanks for the answers, this is how I ended up doing it:</p>

<pre><code>for file in glob.glob(os.path.join(dir, '*.[xX][lL][sS]')):
    shutil.move(file, os.path.join(os.path.dirname(file), os.path.pardir))
</code></pre>
