Scratch Folder (Environment setting)

The Scratch Folder environment setting is the location of a folder you can use to write file-based data, such as shapefiles, text files, and layer files.

Writing output to the scratch folder will make your code portable, as this folder will always be available or created at execution time.

Usage notes

  • The scratch folder is guaranteed to exist when your script or model runs; and you will have write access to this folder.
  • The Scratch Folder environment is read-only; you cannot set the location directly.
    • If the Scratch Workspace environment has been set, the Scratch Folder environment will reflect this value first.
      • If your Scratch Workspace environment references a geodatabase, the Scratch Folder environment value will be the folder in which the geodatabase resides.
      • If your Scratch Workspace environment points to a folder, the Scratch Folder environment will be a folder named scratch in the scratch workspace location. If the folder named scratch does not exist, one will be created.
    • If the Scratch Workspace environment has not been set, the Scratch Folder environment defaults to a folder within the AppData section of the User Profile, typically C:\Users\<user_name>\AppData\Local\Temp\1\scratch.
  • Files written to the Scratch Folder environment are not automatically deleted. You will need to do your own cleanup.

Dialog syntax

Note:

The Scratch Folder environment is only available in Python and models.

Scripting syntax

arcpy.env.scratchFolder

Script example

import arcpy

print(arcpy.env.scratchFolder)

Related topics