I have a situation where I have hundreds of files that have been incorrectly named. The files all follow a pattern of _XXXX_other.jpg and I need to move all of them over to _XX_XX_other.jpg.
The solution here, obviously, will have multiple pieces. Unfortunately I couldn't even put together a simple regex to match the file pattern. I tried using:
ls -l | grep -e *.[0-9]{4}"_other.jpg"$
Unfortunately this matched everything in the directory instead of just the files w/ that pattern. If I could have figured out the grep I was going to do a for loop, as such:
for i in $(<grep here>); do mv "$i" "${i/<same regex here/?????}"; done
I gave up on my method but I am curious if there is actually a way to do this in a bash script or just from the command line.