At the moment, you are executing the execdir command for every file found.
Another approach would be to use find's printf flag and print the size of the files and the path/name only, sorting the output before printing just the move command for the largest file and piping the command to sh to execute.
find . -name "*.txt" -printf '%s,%f,%h
' | sort -n | awk -F, '{ fil=$2;dir=$3 } END { print "mv ""dir"/"fil"" ""dir"/folder.jpg"" }'
We pipe through to sort to have the largest file at the bottom of the output, we then pip through to awk to get the last record, constructing the actual mv command.
Once you have verified that the mv command is as expected, execute it by piping through to sh and so:
find . -name "*.txt" -printf '%s,%f,%h
' | sort -n | awk -F, '{ fil=$2;dir=$3 } END { print "mv ""dir"/"fil"" ""dir"/folder.jpg"" }' | sh
To perform the solution on each directory, run:
while read line;do find "$line" -name "*.txt" -printf '%s,%f,%h
' | sort -n | awk -F, '{ fil=$2;dir=$3 } END { print "mv ""dir"/"fil"" ""dir"/folder.jpg"" }' | sh;done <<< "$(find . -type d)"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…