Select to view content in your preferred language

Why is c:\Temp1 not a folder?

1912
9
Jump to solution
08-13-2014 06:15 AM
JohannesBierer
Frequent Contributor

Defined a Parameter as data type folder and put in c:\Temp1 which results in this error message?

File "R:\Karto\zGIS\Projekte\MaP_FFH_Richtlinie_Toolentwicklung\python\FangenSymDiff.py", line 50, in <module>

    arcpy.FeatureClassToShapefile_conversion(Aenderung_MToS, Aenderung_MToS_CopyFeatures)

  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\conversion.py", line 2550, in FeatureClassToShapefile

    raise e

ExecuteError: Fehler bei Ausführung. Parameter sind ungültig.

ERROR 000840: Der Wert ist kein(e) Ordner.

Fehler beim Ausführen von (FeatureClassToShapefile).

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

I never assume and always convert path selections

aPath = aPath.replace("\\",:/")

when I select aPath from a tool within Arctoolbox...just incorporate within your script

View solution in original post

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus

"c:\temp1"

must be written in raw format

r"c:\temp1"

with double backslashes

"c:\\temp1"

or with forward slashes

"c:/temp1"

of course this assumes you have a folder of this name in the first place

0 Kudos
JohannesBierer
Frequent Contributor

Hi Dan,

the script is used in the toolbox Folder as Parameter (Folder Data Type) - so the input there sould be right?

0 Kudos
DanPatterson_Retired
MVP Emeritus

I never assume and always convert path selections

aPath = aPath.replace("\\",:/")

when I select aPath from a tool within Arctoolbox...just incorporate within your script

0 Kudos
JohannesBierer
Frequent Contributor

ok, why .replace("\\",:/")?

Isn't it old, new?

0 Kudos
DanPatterson_Retired
MVP Emeritus

in python the backslash is used as a literal...meaning if you want a backslash you have to preceed the backslash you want with another one (check python documentation), so the expression I gave you means "replace the backslash with a forward slash"

0 Kudos
curtvprice
MVP Alum

It is disconcerting because if there is no corresponding escape sequence, the string is passed along unmodified. The escape sequences are case sensitive, just to add to the confusion.

>>> print "C:\TEMP  C:\temp"

C:\TEMP  C:    emp

Here's the help page I always refer people to:

ArcGIS Help 10.2 - Paths explained: Absolute, relative, UNC, and URL

curtvprice
MVP Alum

Dan, did you mean:

aPath = aPath.replace("\\","/")

AdamCox1
Deactivated User

Personally, I always use one of the following methods and don't have any trouble anymore

1. put an r in front of the path and it will be interpreted literally.

path = r"C:\Temp1"

2. os.path.join() is great also, especially for constructing dynamic paths because you can pass variables as arguments.  Also good if cross platform considerations are an issue

path = os.path.join("C:","Temp1")

3. also good for dynamic paths, because you can through variables in for the directory names:

path = r"{0}\{1}".format("C:","Temp1")

4. finally, it's not very concise, but you can always use os.sep

path = "C:" +os.sep+"Temp1"

Hope this is helpful!

JohannesBierer
Frequent Contributor

Very helpful, thanks.

To tell you the truth, there was no path problem, I used two times one input parameter 🙂

0 Kudos