Search code examples
bashloopsglobfile-renamebatch-rename

Removing part of filename with bash


Why this script does not work?

for filename in bre*; do 
    rename 's/bre//'; 
done

I have files starting with bre in the directory and I would like to delete this part from filenames. It is running and nothing will happen and it is not finished. Thank you


Solution

  • You didn't tell rename what files it should rename.

    You don't need the loop, since you can use a wildcard for the filename arguments to rename

    rename 's/bre//' bre*