FILECOUNT=`ls /source_file_path/${1}/*.[Tt][Xx][Tt] /source_file_path/${1}/*.[Pp][Dd][Ff] | wc -l`
Somehow this statement will not work if I schedule it in the cronjob. But it will work if I manually execute the script. Feeling so weird. I was lucky that someone from the forum giving me an advise saying that find command would be a better choice for my use case. Here comes the new code.
FILECOUNT=$(find /source_file_path/${1}/ -maxdepth 1 -name "*.[Pp][Dd][Ff]" -o -name "*.[Tt][Xx][Tt]" | wc -l)
Beware of the maxdepth option, I made a mistake that if I miss this option in the find command, it will return me all files located in the subfolder as well.
No comments:
Post a Comment