12.5. Creating a Directory: The `Mkdir` Factory
Prev | Chapter 12. Platform-Independent File System Manipulation | Next

## 12.5. Creating a Directory: The `Mkdir` Factory

If you need to create a directory, use the `Mkdir` factory. For example, if we need to process a file in a temporary directory in which the processing tool will create other files that we don't care about, you could use:

    Command(
        "file.out",
        "file.in",
        action=[
            Delete("tempdir"),
            Mkdir("tempdir"),
            Copy("tempdir/${SOURCE.file}", "$SOURCE"),
            "process tempdir",
            Move("$TARGET", "tempdir/output_file"),
            Delete("tempdir"),
        ],
    )

Which executes as:

    % scons -Q
    Delete("tempdir")
    Mkdir("tempdir")
    Copy("tempdir/file.in", "file.in")
    process tempdir
    Move("file.out", "tempdir/output_file")
    scons: *** [file.out] tempdir/output_file: No such file or directory

Prev | Up | Next
12.4. Updating the Modification Time of a File: The `Touch` Factory | Home | 12.6. Changing File or Directory Permissions: The `Chmod` Factory