Code:
awk 'BEGIN{
q="\047"
path="/path/to/search"
cmd="find "path" -type f -name \"*_*.jpg\""
while(( cmd|getline f )>0){
m=split(f,file,"/")
gsub(/_/,"-",file[m])
newfilename = join(file,1,m,"/")
mv = "mv "q f q" "q newfilename q
print mv
#system(mv) #uncomment to use
close(mv)
}
close(cmd)
}
function join(array, start, end, sep, result, i)
{
if (sep == "") sep = " "
else if (sep == SUBSEP) sep = ""
result = array[start]
for (i = start + 1; i <= end; i++)
result = result sep array[i]
return result
}'