@NishimuraChinatsu-9854 Thanks for reaching out. The better way to design your workflow will be as below. In the below workflow for the individual attachments, I am trying to get the extension string and creating different folders for different extensions, and it will add the files to only to that extension folder.
Folder Path : /attachments/@{substring(items('For_each')?['name'],add(lastIndexOf(items('For_each')?['name'],'.'),1),sub(length(items('For_each')?['name']),add(lastIndexOf(items('For_each')?['name'],'.'),1)))}"
For your reference attaching the code view and function reference document. You can update it as per your business needs. Feel free to get back to me if you have any queries or concerns.
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.