updated script to support attached files to md file