You would use Keyboard Maestro's "Execute Shell Script" action.
If the folder is always the same, you could specify it in the shell script:
chdir "$HOME/Documents/My Folder/"
for file in *.md; do
echo 'MyString' >> "$file"
done
chdir
stands for Change Directory
(you can also abbreviate it as simply cd
BTW / FWIW I would recommend adding a blank line or two before your 'MyString' but that's just personal preference. When using echo
you can add a blank line by adding \n
(n
as in newline
)
This would add two blank lines to the end of the file and then MyString
:
chdir "$HOME/Documents/My Folder/"
for file in *.md; do
echo '\n\nMyString' >> "$file"
done
Again, that's just personal preference and you may have reasons not to want that, but I thought I'd mention it.
If you want to be able to select a folder in Finder and tell Keyboard Maestro to append to all the files in the selected folder…
…then you would want to refer to the Finder's Selection page from the Keyboard Maestro Wiki:
https://wiki.keyboardmaestro.com/collection/Finders_Selection
Feel free to ask more questions if you need more help. Happy to share what shell script + Keyboard Maestro knowledge I have to offer.