I'm currently a bit stuck, trying to adjust filenames within a folder tree if they have one or both of the following:
Remove 'S00' - 'S99' -that part is to be cut out of the filename.
s/[sS](0[1-9]|[1-9][0-9])/
could do that I thinkAny free standing double digits get an 'E' in front of them. Find
/\b([0-9]{2})\b/
and substituteE$1
somehow
Example: any of these
[lorem ipsum] dolor sit amet 07 [consetetur][1080p].mkv
[lorem ipsum] dolor sit amet S04 07 [consetetur][1080p].mkv
[lorem ipsum] dolor sit amet S04 E07 [consetetur][1080p].mkv
are changed to
- [lorem ipsum] dolor sit amet E07 [consetetur][1080p].mkv
within their respective subfolders.
Ultimate goal is to automate the process of renaming files as they appear (that latter bit I have to figure out once I'm done with this) so the kodi scraper can recognize episodes
This is how far I got, as you can see, its still a mess as I've found this rename script here a while ago, but I don't know how to properly apply the regex, I just slapped it in
#!/bin/bash
start_dir="//srv/MEDIA2/"
find "$start_dir" -name '*.*' -type f \
|sort \
|while read name; do
((i++))
mv -i "$name" \
#remove season part
"$(printf 's/[sS](0[1-9]|[1-9][0-9])/' "$(dirname "$name")" $((i)) "$(basename "$name")")"
#prepend E to free standing double digits
"$(printf 's/\b([0-9]{2})\b/' "$(dirname "$name")" $((i)) "$(basename "$name")")"
done
Currently it returns
//home/user/./rnscript.sh: line 14: s/[sS](0[1-9]|[1-9][0-9])/: No such file or directory
//home/user/./rnscript.sh: line 16: s([0-9]{2}/: No such file or directory
If anyone with knowhow in that area could help me out to get this running, it would be greatly appreciated.