5 # Output an org compatible structure representing the filesystem from
6 # the point passed on the command line (or . by default).
12 # dir2org.zsh [DIR]...
15 # Phil Jackson (phil@shellarchive.co.uk)
23 printf "%${depth}s %s" "" |
tr ' ' '*'
27 function scan_and_populate
{
31 headline
${depth} "${dir}"
33 # if there is no files in dir then just move on
34 [[ $
(ls "${dir}" |
wc -l) -eq 0 ]] && return
38 for f
in $
(ls -d "${dir}"/*); do
39 if [ -d "${f}" ]; then
40 scan_and_populate
${depth} "${f}"
42 headline
${depth} "[[file://${f}][${${f##*/}%.*}]]"
50 local scan_dir="${1:-$(pwd)}"
53 scan_and_populate ${depth} "${scan_dir}"