Renomeando arquivos em massa

Hoje precisei de espaço no meu pendrive e vi uma pasta com dezenas de fotos no formato “arquivo.CHK”. Eu teria que renomeá-las para JPG. Mas como fazer isso de modo rápido?

Numa simples busca no Google, a resposta veio em segundos: PyRenamer.

Lendo o post do Diggao, que é muito dissertativo, você poderá agilizar o processo de forma rápida. E tudo o que precisa fazer é ir no menu Aplicativos > Acessórios > Terminal e digitar:

sudo apt-get install pyrenamer

O programa estará no menu Aplicativos > Acessórios > PyRenamer

Feito!

4 comentários em “Renomeando arquivos em massa”

  1. Eis uma maneira que poderia ser feita rapidamente pelo terminal, sem o uso de qualquer outro programa para instalar. Considerando que você está no diretório que contém todas as imagens, poderia ser assim:

    $ ls
    arquivo1.chk arquivo2.chk arquivo3.chk arquivo4.chk arquivo5.chk arquivo6.chk
    $ for foto in *; do
    > mv “${foto}” ${foto%’.’*}.jpg
    > done
    $ ls
    arquivo1.jpg arquivo2.jpg arquivo3.jpg arquivo4.jpg arquivo5.jpg arquivo6.jpg

  2. Um script para renomear arquivos em massa.
    Salve este texte na pasta (home/.gnome2/nautilus-script) obs: esta pasta esta oculta.
    Agora basta selecionar os arquivos, clicar com o botão direito do mouse, scripts e pronto.
    ————————————————————-
    #! /usr/bin/python
    # -*- coding: utf-8 -*-
    # Requires zenity
    # tip – run: $ sudo apt-get install zenity

    “””
    Copyright (C) 2009-2010 Thiago Bellini

    MassFileRename is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see .

    “””

    import os
    import re
    import sys

    pattern = ”
    files = []

    def makeNewName(oldname, newname, number):
    thename = ”
    suffix = ”
    # This will maintain the extension ex. “.jpg” and turn it lowercase
    if oldname.find(‘.’) != -1:
    oldnameList = oldname.split(‘.’)
    suffix = oldnameList[len(oldnameList)-1].lower()

    if suffix != ”:
    thename = newname + ‘_’ + number + ‘.’ + suffix
    else:
    thename = newname + ‘_’ + number

    return thename

    pattern = os.popen(‘zenity –title “fileRenamer” –entry –text “Enter the Pattern:” –width=320’).read().split(‘\n’)[0]
    #Exit if no files selected, if no pattern entered or if a ‘/’ was found
    if pattern == ”:
    sys.exit(1)

    if pattern.find(‘/’) != -1:
    sys.exit(1)

    for i in sys.argv[1:]:
    files.append(i)

    if files == []:
    sys.exit(1)

    number = 1
    lenFiles = len(str(len(files)))
    if lenFiles == 1:
    #Set default to 2, because “File_01” is better than “File_1” =P
    lenFiles = 2
    for filee in files:
    #Skips folders, symlinks, mountpoints
    if os.path.isdir(filee):
    pass
    elif os.path.islink(filee):
    pass
    elif os.path.ismount(filee):
    pass
    else:
    oldname = os.path.split(filee)[1]
    newname = makeNewName(oldname, pattern, str(number).zfill(lenFiles))
    newfile = os.path.join(os.path.split(filee)[0],newname)
    #Just a precaution, so you won`t loose data ;D
    if filee != newfile:
    while os.path.isfile(newfile):
    number = number + 1
    newname = makeNewName(oldname, pattern, str(number).zfill(lenFiles))
    newfile = os.path.join(os.path.split(filee)[0],newname)
    if filee == newfile:
    break
    os.rename(filee,newfile)
    number = number + 1

Deixe um comentário para Frederico Lamberti Pissarra Cancelar resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *