How to build a path within an existing directory
Note: I am new to Python & SikuliX
I am looking at using SikuliX as an automation replacement for an existing script that I have in HPE UFT.
One of the things I am struggling with is how to create directory structures inside existing folders.
For example, let's say that I have a base folder called "C:\Screenshots" for the storing of screenshots from various applications.
In UFT, I have a VBScript function that checks to see if the full path exists - if it doesn't, it creates it:
(Note that the application name and the test type are determined elsewhere in the script on the fly)
-=-=-=-
FullPath = "C:\Screenshots
Private Function BuildFullPath(ByVal FullPath)
Dim objFSO : Set objFSO = CreateObject(
If Not objFSO.
BuildFullPath objFSO.
objFSO.
End If
Set objFSO = Nothing
End Function
-=-=-=-
The above function will iterate through the folder structure, and if any portion of the path doesn't exist, it will create it.
I tried the below code in SIkuliX.
(The folder structure of "C:\Screenshots
-=-=-=-
import os
FullPath = "C:\Screenshots
os.mkdir(FullPath)
-=-=-=-
SikuliX returned the following error:
OSError: (17, 'File exists', 'c:\\screenshot
Part of the challenge is that the script will not always know how deep the given folder structure will already go. The script will need to determine this, and then create the missing folders as needed.
The VBScript function outlined above is simple & fast in its loop with the FileSystemObject. Is there a way to do something similarly elegant within Python & SikuliX?
Side question: can Python discern between a directory and a file? The error returned leads me to believe that it is confusing a an existing folder as an existing file.
Thanks in advance,
Ron Turrentine
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Ron Turrentine
- Solved:
- Last query:
- Last reply: