79593859

Date: 2025-04-26 11:21:37
Score: 1
Natty:
Report link

I want to do simple string replacements with sed to rename some files. Unfortunately it does not work the way I expect. My Input (these files):

Hopefully the answer/post of @jhnc covered all of your question but have a look at this link https://mywiki.wooledge.org/BashPitfalls#for_f_in_.24.28ls_.2A.mp3.29


Now, Another bash approach using an array and a loop.

#!/usr/bin/env bash

shopt -s nullglob
old_files=(*.flac)
new_files=("${old_files[@]#Djrum - Under Tangled Silence - }")
shopt -u nullglob

for i in "${!old_files[@]}"; do
  echo mv -v "${old_files["$i"]}" "${new_files["$i"]// /.}"
done

Remove the echo if you're satisfied with the output/outcome


Reasons:
  • Blacklisted phrase (1): this link
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @jhnc
  • High reputation (-1):
Posted by: Jetchisel