Fastest way to replace elements of a file's path and extension?
<p>Given the path of a file:</p>

<pre><code>file = "/directory/date/2011/2009-01-11 This is a file's path/file.jpg"
</code></pre>

<p>How can I quickly replace it with:</p>

<pre><code>new_file = "/newdirectory/date/2011/2009-01-11 This is a file's path/file.MOV"
</code></pre>

<p>Changing both directory for "newdirectory" and ".jpg" for ".MOV"</p>
