Scratch Folder
The Scratch Folder is the location of a folder you can use to write file-based data, such as shapefiles, text files, and layer files. It is a read-only environment that is managed by ArcGIS.
The Scratch Folder environment complements the Scratch Workspace environment. Its primary purpose is for use by scripts and models as geoprocessing services, with the added focus of pointing only to a known folder. When ArcGIS for Server executes a geoprocessing task, the Scratch Folder is always available to write output to. This environment is also useful in authoring scripts and models for use on the desktop. Writing output to the Scratch Folder will make your tool portable, because this location will always be available or created at execution time.
Usage notes
- The Scratch Folder is guaranteed to exist when your script or model runs; you will have write access to the folder.
- The Scratch Folder environment is read-only; you cannot set the location directly.
- If your map document has a Scratch Workspace set, the Scratch Folder will reflect this value first.
- If your Scratch Workspace references a geodatabase, the Scratch Folder environment value will be the folder in which the scratch geodatabase resides.
- If your Scratch Workspace points to a folder, the Scratch Folder will be a folder called scratch inside the Scratch Workspace location. If the folder called scratch does not exist inside the Scratch Workspace, one will be created.
- If there is no Scratch Workspace set in your map document, or you're working in an environment where the Scratch Workspace has not been explicitly set, the Scratch Folder defaults to the current user's temporary files directory. This directory is typically at C:\Users\<user>\AppData\Local\Temp on Windows 7 or C:\Documents and Settings\<user>\Localsystem\Temp on Windows XP.
- If your map document has a Scratch Workspace set, the Scratch Folder will reflect this value first.
- Files written to the Scratch Folder are not automatically deleted. You will need to do your own cleanup.
- The Scratch Folder can be used inside your Python scripts. Make sure to set your Scratch Workspace variable prior to using it; this way, you know where the output will be generated.
Dialog syntax
The Scratch Folder environment is only available in Python and models.
Scripting syntax
arcpy.env.scratchFolder
Script example
import arcpy
arcpy.env.scratchWorkspace = "c:/LandUse/ForestCover"
# c:\LandUse\ForestCover\scratch
print arcpy.env.scratchFolder