"perl -pi -e 's/abcd/dcba/' filename" will basically do the substitution and listing all the files in a file then prepending this string in front of each filename, will produce a shell script out.sh which would run this perl command on each of the files.
If I understand what you're asking, this code should do what you want (ksh):
for i in `lx`; do
FOUND=`grep ABCD $i`
if [ "$FOUND" ]
sed -e 's/ABCD/DCBA/g' < $i > $TMP
mv $TMP $i
echo "The file $i does not include the word ABCD"
This script reads each file in your_pathname, searches for the string ABCD, and either replaces it with DCBA or alerts you that the string ABCD was not found.
remember you are redirecting output to a file and then moving the file back to the original
what if the file sizes are of the order of tens of MBs.
secondly, the shell script would compulsorily do it for all the files in the directory.
but while using a file, you can customize your renaming process.