jupyter / jupyter/notebook

Can't cd into a specific directory

Open
#4,786 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I'm currently using the following snippet to create a directory with the name of today's date and then change the current the directory to the new directory...
```python
date_dir = datetime.date.today().strftime("%y-%m-%d")
os.makedirs(date_dir, exist_ok=True)
os.chdir(date_dir)
```
...and wanted to implement the same concept using the % cell magic, but am unable to do so as of writing...

Any advice?

**Code that isn't working**
```jupyter
%%bash
date_dir=`date +"%y-%m-%d"` # Use linux date command to get today's date and initialize to the `date_dir` variable
mkdir -p $date_dir # Make a new directory (if it doesn't already exist) and assign the name as the value of the `date_dir` variable
cd "`ls -t | head -1`" # This is supposed to list all elements in the current directory, sorted newest first,
# only take the newest element and change directory into the newest element
```

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or entry point is named. Start by tracing how the %%bash cell magic executes commands and handles working-directory changes; done means establishing whether the requested directory change can persist and addressing or documenting that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, jupyter-notebook, python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.