Please help with my task:
I have a folder with three sub-folders containing six files each. There are two files in each sub-folder with :nopm in their file names.
I need to create a shell script that checks all the folders and their sub-folders. If there are any file names with :nopm as part of the name, this (:nopm) should be removed from the name. If there is another file with the same name, as in :nopm removed, it should be deleted and every interaction should be logged into a file named log.txt.
I have a directory: Example_September
In this directory I have three sub-directories:
fruit/ car/ vegetable/
These three directories have six files each:
fruit : apple pear banana melon grape :nopmlime car : fiat mercedes ferrari audi suzuki :nopmaudi vegetables : bean broccoli cabbage corn carrot :nopmgarlic In the directory fruit the script should rename :nopmlime to lime In the directory car the script should delete :nopmaudi
All rename and remove must log to a .txt file like:
I remove the file(s) I rename the file(s)
I should complete the task like this. Can you help to repair this?
for if find /data/irm/Example_September -name :nopm: do mv filename1 filename2 echo I rename the file. elif rm file echo I remove the file. fi >> /data/irm/Example_September/log.txt \;