Specify file type in For Each

I'm using the For Each command on a set of files in a folder. However, I don't want to select all the files, but only those with a certain file extension. Is there a way to say: For Each file in CertainFolder with the extension .doc, do the following actions ?

Not exactly, but you can achieve what you want.
The For Each has a variable of FilePath for each file it finds.
You can then use a IF/THEN with a Condition of FileType to identify the files you want to process.

Something like this:

1 Like

ok, that works. thank you. can you clear up a couple of things for me? when you do For Each file in a folder, KM picks up each file, but does that mean it picks up the path of the file? It's not the content of the file, right?

And then, how is file type different from file extension?

I didn't write KM, but that is my understanding.

I think if you google "Mac file type vs extension" you'll get a number of detailed articles.
But, in a nutshell, "file type" is metadata about the file which identifies the type, or kind, of content of the time, like "text", "image", etc.

Whereas "file extension" is just the characters at the end of the file name after the dot. While it usually gives us an indication of the file type, there is no guarantee that it is accurate. It is more associated with what app will open the file, even though even that can depend more on file type.

1 Like