Bash Shell § for filename in *.md; do text=$(head -1 "$filename" | cut -c 3- | sed -e 's/[^A-Za-z0-9 ().,:;_-]//g' | sed -e 's/\ \ / /'); mv "$filename" "$text".md; done # to add [[]] to each cover image sed -i 's/Cover\ Image:\ \(.*.jpg\)/Cover\ Image:\ \[\[\1\]\]/' Renaming Files with Bash § for filename in *.jpg do text=$(tesseract "$filename" stdout | grep "LRP") cp "$filename" renamed/"$text".jpg done ## | cut -f2 -d":"| to only pick the second field to rename ## cut -c == means skip the first and move to the second character ## head -1 is used to only output the first line, isn't needed in this case for filename in *.png do text=$(tesseract "$filename" stdout | grep "KH" | awk '{print $2} | cut -c 2-) cp "$filename" renamed/"$text".png done