I have folder which contains many .mkv files that I'd like to rename without having to manually do so.
The pattern is this:
... [XVC]_Control_-_10_-_Doctors_[SCB055Y].mkv [XVC]_Control_-_11_-_Engineers_[50OPZ00].mkv ... I'd like the results to be:
... Control-10-Doctors.mkv Control-11-Engineers.mkv ... I've tried using find and piping it through sed and tr, but I can't seem to get it to work.
This is what I've tried so far:
find . -iname "*.mkv" -exec sed -e 's/\[[^][]*\]//g' {} \; find . -type f "*mkv" | sed 's/\[[^][]*\]//g' | tr -d '_' find . "*.mkv" -type f -print0 | xargs -0 sed -i '' -e 's/\[[^][]*\]//g' | tr -d '_' find . -iname "*.mkv" -exec rename 's/\[[^][]*\]//g' .mkv '{}' \; find . -iname "*.mkv" -exec rename -n 's/\[[^][]*\]//g' {} ";" And several others, but none seem to work. I find it puzzling that the command command below works:
(input) echo '[XVC]_Control_-_10_-_Doctors_[SCB055Y].mkv' | sed 's/\[[^][]*\]//g' | tr -d '_'` (output) Control-10-Doctors.mkv EDIT:
$ file $(which rename) /usr/bin/rename: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=d7b5a08ee8556c59dbdda26e998e20d4762c2bbc, for GNU/Linux 3.2.0, stripped rename -n 's/\[.+?\]//g; s/_//g' *mkv rename: not enough arguments Try 'rename --help' for more information.
perland therenamecommand installed, if that's what you're thinking of.renamecommand you used is the one fromutil-linuxor if it is the perl script often installed asrenameon Debian-based systems. What doesfile $(which rename)return? Do you have eitherprenameorperl-renameinstalled? See What's with all the renames: prename, rename, file-rename?file $(which rename)will only show a link, and you have to follow that link to find what kind of program it points to (sometimes in several steps). For this reason I made the shellscriptwhat-about, that does that job for us. See this link.dpkginstalled; is there an alternative I can use to substitute the command inside the script?