Rename new files without interfering with old ones

Asked

Viewed 42 times

0

I need to rename some files .srt, but if I do it in the current way it will impact the old files.

I have several subtitle files that I’ve already edited for pt-BR.srt, but with the addition of new files, if I use my script, it will rename the old ones, playing one more pt-BR in front and thus getting duplicated.

What I need is for the script to identify the file .srt pure, and renamed to pt-BR.srt without renaming the ancient.

Below follows the script I use.

for f in $(find . -name "*.srt"); do mv "$f" "$(echo $f | sed 's/\.srt/.pt-BR.srt/;')"; done

2 answers

0

Good afternoon,

A simple way would be like this

find -type f -not -name "*pt-BR.srt" -name "*.srt"

0

I solved the problem by adding the command grep. With that, I got what I really wanted.

Stayed like this:

for f in $(find . -name "*.srt" | grep -v "pt-BR"); do mv "$f" "$(echo $f | sed 's/.srt/.pt-BR.srt/;')"; done

Browser other questions tagged

You are not signed in. Login or sign up in order to post.