Score:0

Remove characters from file name - between [ and ]

tr flag

i download videos from YouTube for my hobby. The filenames contain some random characters between the [ and ]. E.g. filename [vbnghztresku].webm.

My partial solution starts as follows:

find /medien -type f -name "*.webm" -exec rename ????????

However I a have difficulties for the regular Expression part of the command.

Could some experienced user guide me to working solution, please ?

Best regards, Bleckie

Score:0
hr flag

[ and ] are metacharacters in regular expression syntax - to match them literally, they must be escaped. So for example:

$ rename -n 's/ \[.*?\]//' *.webm
rename(filename [vbnghztresku].webm, filename.webm)
Bleckie avatar
tr flag
Well steeldriver, thanks for your suggestion. I completed my script with your suggested extension and ran the following completed script: find /medien -type f -name "*.webm" -exec rename -n 's/ \[.*?\]//' *.webm {} +. However it failed to do the proposed conversion. What went wrong ? I really appreciate your kind suggestion. regards, Bleckie
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.