0

I use my synology DS1515+ and DSM 6.2.2.

I'd like to remove specific section in name of many files.

For example;

abcde(test).mp4 → abcd.mp4

love(1).mp4 → love.mp4

Section that from ( to ) in filename should be removed.

Letters between ( and ) are different in many files.

How can I do this? please help me.

Thank you very much in advance.

1 Answer 1

0
#!/bin/bash
for i in *; do
    echo "Old file: $i"
    new=$(echo "$i" | sed -e 's/\s*(.*)//g')
    echo "New file: $new"
done

Old file: abc (csd).mp4 New file: abc.mp4 Old file: def(123).mp4 New file: def.mp4

Just replace echo with mv "$i" "$new".

2
  • Sorry, I missed the first crucial sentence of your post. Commented Apr 6, 2020 at 16:05
  • Thankyou for your comment. doesn't it works? Commented Apr 6, 2020 at 16:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.