I am new to using Bash scripting, but I have discovered a few solutions that use it to either remove or rename the filename for files within directories and sub-directories in Ubuntu 16.04. For example, my file structure is shown below. So, the
FolderFruit,,, is the filename of our main directories.
SubFolder_Food_Banana are the filenames of our subdirectories.
ListBanana are the filename of our individual files.
>FolderFruit,,, >> SubFolderApple?? >>> ListAppleFood.txt >> SubFolder!!Kiwi >>> ListKiwiFood.pdf >> SubFolder_Food_Banana >>> ListBanana.csv
The goal is to change the filenames above into as shown below by removing any punctuation (e.g., ? and !) and the string 'Food' that appear among those filenames.
>FolderFruit >> SubFolderApple >>> ListApple.txt >> SubFolderKiwi >>> ListKiwi.pdf >> SubFolderBanana >>> ListBanana.csv
So far, I manage to script it as below, but it is not working. Thus, I would like to get help from any experienced Bash or Linux users.
shopt -s globstar for f in ./**; do sed 's/\([[:punct:]]\)/\\\1/g' "$f" done