Como remover um número dos nomes dos arquivos?

1

como remover um número disponível em um nome de arquivo?
No meu exemplo abaixo, como você pode ver, eu quero remover zero

$ rename -n 's/Season\ (\d{2})\ Episode\ (\d{2}).+(\D{2})/Season\ \ Episode\ .mp4/' *

Season 01 Episode 01.mp4 renamed as Season 01 Episode 01.mp44  
Season 01 Episode 02.mp4 renamed as Season 01 Episode 02.mp44  
Season 01 Episode 03.mp4 renamed as Season 01 Episode 03.mp44  
Season 01 Episode 04.mp4 renamed as Season 01 Episode 04.mp44  
Season 01 Episode 05.mp4 renamed as Season 01 Episode 05.mp44  
Season 01 Episode 06.mp4 renamed as Season 01 Episode 06.mp44  
Season 01 Episode 07.mp4 renamed as Season 01 Episode 07.mp44  
Season 01 Episode 08.mp4 renamed as Season 01 Episode 08.mp44  
Season 01 Episode 09.mp4 renamed as Season 01 Episode 09.mp44  
Season 01 Episode 10.mp4 renamed as Season 01 Episode 10.mp44  
Season 01 Episode 11.mp4 renamed as Season 01 Episode 11.mp44  
Season 01 Episode 12.mp4 renamed as Season 01 Episode 12.mp44  
Season 01 Episode 13.mp4 renamed as Season 01 Episode 13.mp44  
Season 01 Episode 14.mp4 renamed as Season 01 Episode 14.mp44  
Season 01 Episode 15.mp4 renamed as Season 01 Episode 15.mp44  
Season 01 Episode 16.mp4 renamed as Season 01 Episode 16.mp44  
Season 01 Episode 17.mp4 renamed as Season 01 Episode 17.mp44  
Season 01 Episode 18.mp4 renamed as Season 01 Episode 18.mp44  
Season 01 Episode 19.mp4 renamed as Season 01 Episode 19.mp44  
Season 01 Episode 20.mp4 renamed as Season 01 Episode 20.mp44  
Season 01 Episode 21.mp4 renamed as Season 01 Episode 21.mp44  
Season 01 Episode 22.mp4 renamed as Season 01 Episode 22.mp44  
Season 01 Episode 23.mp4 renamed as Season 01 Episode 23.mp44  
Season 01 Episode 25.mp4 renamed as Season 01 Episode 25.mp44  
Season 01 Episode 26.mp4 renamed as Season 01 Episode 26.mp44  
Season 02 Episode 00.mp4 renamed as Season 02 Episode 00.mp44  
Season 02 Episode (this zero needs to be removed)***0***15.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode ***0***16.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode ***0***17.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode ***0***18.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode ***0***19.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode 01.mp4 renamed as Season 02 Episode 01.mp44  
Season 02 Episode ***0***20.mp4 renamed as Season 02 Episode 02.mp44  
Season 02 Episode ***0***21.mp4 renamed as Season 02 Episode 02.mp44  
Season 02 Episode 02.mp4 renamed as Season 02 Episode 02.mp44  
Season 02 Episode 03.mp4 renamed as Season 02 Episode 03.mp44  
Season 02 Episode 04.mp4 renamed as Season 02 Episode 04.mp44  
Season 02 Episode 05.mp4 renamed as Season 02 Episode 05.mp44  
Season 02 Episode 06.mp4 renamed as Season 02 Episode 06.mp44  
Season 02 Episode 07.mp4 renamed as Season 02 Episode 07.mp44  
Season 02 Episode 08.mp4 renamed as Season 02 Episode 08.mp44  
Season 02 Episode 09.mp4 renamed as Season 02 Episode 09.mp44  
Season 02 Episode 10.mp4 renamed as Season 02 Episode 10.mp44  
Season 02 Episode 11.mp4 renamed as Season 02 Episode 11.mp44  
Season 02 Episode 12.mp4 renamed as Season 02 Episode 12.mp44  
Season 02 Episode 13.mp4 renamed as Season 02 Episode 13.mp44  
Season 02 Episode 14.mp4 renamed as Season 02 Episode 14.mp44  

E como você pode ver, a extensão também não é renomeada corretamente, usando o comando renomear. Eu também sei que o comando rename está errado, por favor, forneça o apropriado.

    
por devilz 19.11.2016 / 10:08

1 resposta

2

A seguinte expressão mais simples pode ser suficiente:

rename -n 's/Season (\d{2}) Episode 0*(\d{2}).+mp4/Season  Episode .mp4/'
  • Use um 0* inicial com o segundo grupo para capturar 0s extras antes do número do episódio de dois dígitos.
  • O último grupo não é necessário.
  • Você não precisa escapar de espaços.
por muru 19.11.2016 / 10:38