2

I am running my script from ArcMap and I have the Catalog window open on the side. I delete some extra files in the end of my script but I have to refresh the Catalog window to see them go. So I decided to use the following code to refresh it automatically:

import arcpy 
from arcpy import env
import os.path

# Parameters
XS = arcpy.GetParameterAsText(0)

# Environment Definition
desc = arcpy.Describe(XS)
path = desc.path
env.workspace = path #Everything is saved at *path*

arcpy.RefreshCatalog(path)

But it doesn't work either. Any idea what is missing here?

I am running my script though a toolbox. And my files are located at path.

  • 1
    How is the script being executed? In the python window or through a script or tool? Is the path to a file or folder? – Barbarossa Oct 8 '13 at 19:11
  • @Barbarossa: I revised my post accordingly. – Arash Oct 8 '13 at 19:22
  • 1
    I've just experimented with the command. arcpy.RefreshCatalog(path) seems to work on folders and geodatabases from the python window in ArcMap. It also works on geodatabases from a script tool, but not on folders. Is this what you have experienced as well? – Barbarossa Oct 8 '13 at 19:31
  • @Barbarossa: I have not tried it on geodatabases yet, but yes, I am trying to refresh the contents of a folder rather than a geodatabase. – Arash Oct 8 '13 at 19:33
  • 1
    What version of ArcGIS for Desktop are you using? Can you reproduce the issue using the Sample Code from the RefreshCatalog documentation? If so, it would be good to edit that or an alternative test case into your question. – PolyGeo Oct 8 '13 at 21:15
2

I just tested this using ArcGIS 10.2 for Desktop on Windows 7 SP1 (64 bit) and the code below, which I just pasted into the Python window of ArcMap:

import shutil
import arcpy

input_folder = "c:/temp/testFolder"
target_folder = "c:/temp/testFolder_backup"
input_gdb = "c:/temp/test.gdb"
target_gdb = "c:/temp/test_backup.gdb"

# Copy a directory tree to a backup location
shutil.copytree(input_folder, target_folder)
shutil.copytree(input_gdb, target_gdb)

# Refresh the Catalog window for the new directory
arcpy.RefreshCatalog(target_folder)
arcpy.RefreshCatalog(target_gdb)

The Catalog window simply did not refresh to show the new folder or file geodatabase.

I also tried to refresh the folder above using:

arcpy.RefreshCatalog("C:/temp")

but this too had no effect.

As soon as I right-clicked on C:\temp and chose Refresh to do it manually both the new folder and file geodatabase appeared.

I recommend that you report to your local Esri support that you are experiencing what appears to be bug NIM077922.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.