renaming many files

Linux for blind general discussion blinux-list at redhat.com
Fri Jan 22 20:12:15 UTC 2021


Tim here.  If you have the "rename" package installed

  apt-get install rename

it's as easy as

  rename 's/^renewal talk //' "renewal talk "*

(it has a lot more power under the hood, being able to tap the full
power of perl in how the filename is modified, but stripping off an
initial prefix is an easy use-case)

If you don't, you can use shell modifiers in a for-loop

  for f in renewal* ; do mv -vi "$f" "${f#renewal talk }" ; done

Hope this helps,

-Tim

On January 22, 2021, Linux for blind general discussion wrote:
> I have many files in one directory which have the same two words in
> the beginning of the name. renewal talk 01 eating better
> renewal talk 02 exercise
> and so on.
> With the command line, is there a way of getting rid of ‘renewal
> talk’ for all files and keeping the other words in their names?
> 
> 
> _______________________________________________
> Blinux-list mailing list
> Blinux-list at redhat.com
> https://www.redhat.com/mailman/listinfo/blinux-list





More information about the Blinux-list mailing list