#!/bin/bash for f in `find . -name '*jpg'` do filename=`echo $f|awk -F'/' '{SL = NF-1; TL = NF-2; print $TL "_" $SL "_" $NF}'` cp $f newfolder/$filename done