Finding DOCX files inside a multiple-level folder hierarchy

I’m having problems as I test this solution.

Just to be clear (in my For Each x 2 image) –

Will my FOLDER var get just FOLDERS?
Will my FILE var just get FILES?
Does KM (and these vars) understand the difference between files and folders?

Thanks.

Steve, I'm confused on your objective.

The above solutions provide you with a list of file paths in the main folder and all sub-folders. The For Each Action will allow you to process each file in that list. With that approach you do not need to worry about the sub-folders -- they are included in the path of each file.

If this doesn't clear things up for you, then perhaps you can provide us with more details of exactly what you want to do.

I’m asking these questions for use in other situations. Thanks.

Please start a new topic when the subject changes.
Otherwise, it is confusing for all, particularly for future readers.

OK - but it’s also relevant to this topic.

If this works it could be used to solve this problem without dipping into more complex syntax (Regex, Shell, ASO).
It could keep it all in KM perhaps.

That’s why I am asking the questions here. Depends on the answers to my questions though.

Hey JM,

There's definitely a little overhead there, but we're talking about 0.005 seconds or so for the bare do shell script call.

I do not in fact know if ASObjC is reading file structure on the disk or is reading the system's directory tree, but it's darn fast.

-Chris

Hey Steve,

On Unix everything is considered a file at a very basic level (even folders).

So you can't say folders of selection like you can with AppleScript.

You have to test each and every item you loop over to see what it is.

For each “file” in the Finder Selection
  IF var = directory then
    do something

Keyboard Maestro will do recursion for you once you know you're working with a folder, but you'll have to do the initial test yourself.

-Chris

1 Like

Looking at the original post, would you mind posting your macro for that solution?
Total noob here, having a similar problem i need to fix, and not sure how to implement these shell scripts.

Hey Gideon,

Please be more specific about what you need to accomplish.

-Chris