Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Bulk Renamer

I used ytdlp to download quite a bit of audio books, and music, but the name was not what I wanted, so this script renames things.

# First, remove the a_ prefix
for i in `find . -name "*.mp4"`; do mv "$i" `echo "$i" | sed 's/\/a\_/\//'`; done

# Then remove the duplicate mp4.mp4 extension
find /media/files/mixed/ -name "*.mp3"

# use ffmpeg to get audio only
for i in `find . -name "*.mp4"`; do  ffmpeg -i $i -map 0:a -c copy "${i}.mp4"; done

# then do a single .mp4, echo first, so I can see what will be done
for i in `find . -name "*.mp4.mp4"`; do echo "$i" `echo "$i" | sed 's/\.mp4\.mp4/\.mp4/'`; done

# this was commented out until i verified it would do what I want, then I uncommented
for i in `find . -name "*.mp4.mp4"`; do mv "$i" `echo "$i" | sed 's/\.mp4\.mp4/\.mpx/'`; done 

# remove my source problem files, also commented out while verifying
for i in `find . -name "*.mp4"`; do rm "$i"; done

# rename my temp files back to the correct source name, also commented out while verifying
for i in `find . -name "*.mpx"`; do mv "$i" `echo "$i" | sed 's/\.mpx/\.mp4/'`; done