Create Directories
Updated at:
Creating directories is useful for preparing a project workspace, log directory, or intermediate output directory.
Create directories
Python example:
sandbox.files.make_dir("/tmp/project/src")
sandbox.files.write("/tmp/project/src/main.py", "print('hello')\n")TypeScript example:
await sandbox.files.makeDir("/tmp/project/src");
await sandbox.files.write("/tmp/project/src/main.py", "print('hello')\n");The Python SDK uses make_dir(), and the TypeScript SDK uses makeDir(). The method creates missing intermediate directories automatically. If the directory already exists, the SDK returns the corresponding result, so your application does not need to run mkdir -p first.
Recommendations
Create an isolated working directory for each task, such as /tmp/tasks/<task-id>. This reduces filename conflicts and makes cleanup easier when the task finishes.
Is this page helpful?