ghostdog74's solution below is BRILLIANT and worked well.
Follow up question:
How to do the exact same thing, but only on the file folders in that same file folder tree (recursively)?
DougABC123
Quote:
Originally Posted by ghostdog74
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
}'
|