iainc / Markdown-Content-Blocks

File transclusion syntax for Markdown.
Other
143 stars 7 forks source link

Command to automate file transclusion #1

Closed jsmm closed 7 years ago

jsmm commented 7 years ago

This command automates the creation of a file with a list of all file names in the current folder preceded with /, to be used with iA Writer.

ls -m1 * | sed 's/^/\//'>> file-list.md

It would be nice to create a macOS service or workflow, asking the user to input the name of the file to be created inside the same directory.

onebigclownshoe commented 7 years ago

Yes, this could be done in myriad ways: a service, workflow or script.

Currently, iA Writer allows you to drag and drop files to the editor. You can also select multiple files in Finder and drag them to the editor all at once.

If you'd like to request something above and beyond this in iA Writer, please write to writer+featurerequest@ia.net. As this repository is concerned with the content block spec itself, I'm closing this.

dazzaji commented 7 years ago

Curious - anybody know of a script or open source codebase providing a service to accomplish this?

onebigclownshoe commented 7 years ago

@dazzaji You can take that console command as written and throw it into a bash script:

#!/bin/sh

# This script takes all files in the current directory and adds
# them as content block references to a text file.
# It takes a single argument as the desired filename.
# Usage: collate.sh <filename>

ls -m1 * | sed 's/^/\//'>> $1

Automator lets you run console commands too, so you could build something like this: screen shot 2017-03-27 at 16 58 11

The downside of any of these approaches is the contents in the resulting file will just be listed alphabetically and recursively. Odds are you'll need to reorder these references anyway and so in most cases it is likely faster to drag them into the editor where you want them.