Cd
- Changes the current working directory.
- path
-
- The path to the new working directory.
PICO-8 cartridge storage uses a hierarchical filesystem of directories that corresponds to that of the host operating system. Similar to other command shells, PICO-8 has a notion of a current working directory, a location in this hierarchy where other commands that operate on files, like save
or ls
, perform an action.
When given an argument, the cd
command changes the current working directory. The argument is a path to the new directory, either a relative path from the current working directory or an absolute path from the root of the cartridge storage area. An absolute path begins with a forward slash (/
) character. A relative path does not.
Paths use the forward slash (/
) to separate directory names. This is true even if the host operating system uses a different path delimiter.
A relative path can use two dots (..
) to indicate traversing to the parent directory.
When run without arguments, cd
prints the current working directory's absolute path, and does not change it.
Examples
Consider a cartridge storage area with the following directories and files:
/ demos/ api.p8 jelpi.p8 projects/ helloworld/ hello.p8 hello2.p8 squashy/ squashy.p8
From the PICO-8 command prompt:
> cd demos
The current working directory is now /demos/
.
> cd ..
The current working directory is now /
.
> cd projects/squashy
The current working directory is now /projects/squashy/
.
> cd ../helloworld
The current working directory is now /projects/helloworld/
.
> cd /
The current working directory is now /
.
To print the current working directory:
> cd