I want to thank all you of for your feedback and help. With the script below, I was able to sucessfully run and the changes were applied without moving the file location. EXCEPT there was only one problem; all the files with SPACE within their name were not replaced with a "_". That is if I had a file called "test one.txt"
it is supposed to be replaced to "test_one.txt" however it didn't. :(
any help on how I can add the a few more things within this script to replace the space with an underscrole. or if there is another scrip that I can run seperatly which will replace the file name without moving the location/path of the file.
find . -type f | while read file; do
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" = "$oldfile" ]
then mv "$file" "$dirname/$newfile"
I would add \s inside the sed statement to take care of spaces, but I think most of the problem is with how find pipes to sed when there are spaces in the file name, i'm not sure how to alleviate it