Pergunta

Quero renomear arquivos de:

meu.fi.nome.123.txt, meu.fi.nome.124.txt, meu.fi.nome.125.txt etc2 em

novo.arquivo.link.123.txt, novo.arquivo.link.124.txt ..etc2.

Qual é o melhor comando para fazer isso no Ubuntu 12.04?

Foi útil?

Solução

Você pode fazer algo como:

for file in my*; do mv ${file} "${file/my.fi.name/new.file.link}"; done

Teste:

$ ls -l
total 0
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 my.fi.name.125.txt
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 my.fi.name.124.txt
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 my.fi.name.123.txt

$ for file in my*; do mv ${file} "${file/my.fi.name/new.file.link}"; done
$ ls -l
total 0
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 new.file.link.125.txt
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 new.file.link.124.txt
-rw-r--r--  1 jaypalsingh  staff  0 Feb 25 19:33 new.file.link.123.txt
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top