Find Folder Name Using Wildcard

Find Folder Name Using Wildcard

isocam
Collaborator Collaborator
403 Views
1 Reply
Message 1 of 2

Find Folder Name Using Wildcard

isocam
Collaborator
Collaborator

Can anybody help?

 

I have a number of sub-folders in a main folder thus....

 

C:\Users\Public Documents\Drawing Files\

 

1000 - Thrust Bearing Assembly

1010 - Mixer Shaft Assembly

1020 - Mixer Platform Fabrication

1030 - Mixer Loading Hopper Fabrication

 

Using a wildcard, how can I show the full folder name using a Python script.

 

For example, using the wildcard "1020", the message box should show "1020 - Mixer Platform Fabrication"

 

Many thanks in advance!!!

 

IsoCAM

0 Likes
404 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

The API doesn't do any wildcard searches but you can loop through all of the folders and check to see if each of the names matches you search string in any way you want.

 

In your specific example, you could use the string function startswith like:

if folderName.startswith('1020'):
    app.log(folderName)

 

For a more general wild card search look at the python function fnmatch as discussed here in StackOverflow.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com