How can i rename files with titles like Stargate SG-1 Season 01 Episode 01
to just "s01e01"? Variable numbering of course.
I already have something like this:
for file in *.mkv; do mv "$file" "$(echo "$file" | sed -e "REGEX HERE")
I just need the sed command that does what i need.
Thanks
No need for sed, try this:
#!/bin/bash
for f in *.mkv;
do
set -- $f
mv "$f" s${4}e${6}
done
in action:
$ ls
Stargate SG-1 Season 01 Episode 01.mkv
$ ./l.sh
$ ls
s01e01.mkv
for file in *.mkv; do mv "$file" "$(echo "$file" | sed -e 's/.*\(\S\+\)\s\+\S\+\s\(\S\+\)$/s\1e\2/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With