I am supposed to write a bash script which reads all the .png files
and read the 6th7th8th9th(word/numerals) here it is 1213
and add it on the bottom of the same image file.So that when we open the image file abcd_1213_saj.png , we could see the 1213 on the bottom line
This script should read all the png files in the defined folder do the same task.
Please tell us about .png files . Are they a simple text format suitable for processing in Shell Tools or some other format which needs special programming?
In that case it can't be Portable Network Graphics format (a format which is unsuitable for editing with test-based tools).
You probably need a script someting like this:
#!/bin/bash
cd abc
ls -1d *\.png | while read filename
do
# make sure it is a proper file
if [ -f "${filename}" ]
then
numerals=$(echo ${filename}|cut -c6-9)
# For testing, work on a copy of each file
# Copy the file
cp -p "${filename}" "${filename}.sav"
# Append the text
echo "${numerals}" >> "${filename.sav}"
fi
done