Hi. I'm a complete noob when it comes to scripting. I have approximately 2000 files scattered throughout different locations that I need to rename. The current files have a character, "." , that needs to be replaced with an underscore. I have no clue which route to go about correcting this. Ideally, I could run the script from the root directory and it search & correct the entire drive. Any assistance in the matter is greatly appreciated! Thanks in advance.
Give an example of what the filenames are, is there anything that will identify the filenames?
If you are just looking for files containing a dot, you might run into problems with false positive.
---------- Post updated at 03:25 PM ---------- Previous update was at 03:25 PM ----------
Give an example of what the filenames are, is there anything that will identify the filenames?
If you are just looking for files containing a dot, you might run into problems with false positive.
You can try this
for i in *.sh; do mv "$i" "${i/.sh}"_sh; done
An example would be: A-12345.123.jpg
These need to be changed from A-12345.123.jpg to A-12345_123.jpg
Thanks.
Try this :
for i in *.jpeg*
do
first_part=$(echo "${i}" | cut -d. -f1)
second_part=$(echo "${i}" | cut -d. -f2)
mv "$i" "${first_part}_${second_part}"
done