Passing parameter (directory) to %cd command in ipython notebook
<p>I'm trying to pass a parameter (directory) to a %cd command in ipython notebook as below:</p>

<pre><code> rootdir = "D:\mydoc"
 %cd rootdir
</code></pre>

<p>but i get the following error:</p>

<pre><code> [Error 2] The system cannot find the file specified: u'rootdir'
 D:\mydoc
</code></pre>

<p>when i'm doing </p>

<pre><code> %cd D:\mydoc
</code></pre>

<p>This obviously works but i want to be able to specify my working directories using parameters...</p>

<p>Many thanks who can help me.</p>

<p>Best Wishes</p>

<p>You can use <code>$</code> to use the value in a variable.</p>

<pre><code>%cd $rootdir
</code></pre>

python directory ipython parameter-passing jupyter-notebook