Renommer des fichiers rapidement et en quantité
- Avec l'explorateur Windows
- Il faut pour cela qu’une partie du nom de fichier soit identique, c’est cette partie que vous pouvez renommer et modifier (en pratique si les noms sont complètement différents, on peut quand même ajouter un préfixe/suffixe).
- La méthode est assez simple:
- Sélectionnez tous les fichiers que vous souhaitez renommer.
- Ensuite, faites un clic droit renommer sur un des fichiers, n’importe lequel.
- Modifiez le partie du nom que vous souhaitez changer.
L’explorateur de fichiers va alors appliquer le changement de nom à tous les fichiers qui ont été sélectionnés.
Avec un outil, comme si on éditait du texte : https://github.com/segoja/mass-file-renamer/releases/tag/v0.5.6 (installation: cliquer à droite sur latest release)
- Renomer pleins de fichiers dans un dossier avec un script Python
- Demander à chat gpt
- installer Python (dispo sur le windows store pas besoin des droits d’admin)
- installer Vscode avec les add-on python (dispo sur le windows store pas besoin des droits d’admin)
- Coller le script dans l’IDE et l’executer
- Exemple:
- Demande à chat gpt
Generate a python script for windows. It renames all the pdf files in a specific folder (and also its subfolders). The name starts with “NOM DE FICHIER” and add the date of creation, the name of the user and increment the filename by 1
Script pour renommer des fichiers, ici je garde que la ref du fichier (le premier mot qui commence par +)
import os from PIL import Image folder_path = r"\\linux\Ferro\affaires\Maintenance Locomotives TTH\5 - Méthodes\5.4 Plans\Fichiers pour ouverture des liens\localisations élec" # Replace with the path to your folder # Fetch each file name in the folder file_names = os.listdir(folder_path) # Iterate over each file name for file_name in file_names: file_path = os.path.join(folder_path, file_name) # Check if the file is a PNG image if file_name.lower().endswith(".png"): # Split the file name into words words = file_name.split() # Iterate over each word for word in words: # Check if the word starts with "+" if word.startswith("+"): # Create a new file name with the word as filename new_file_name = word[0:] + ".png" # Create a new file path with the new file name new_file_path = os.path.join(folder_path, new_file_name) # Make a copy of the original image with the new file path with Image.open(file_path) as img: img.save(new_file_path) print(f"Saved a copy of '{file_name}' as '{new_file_name}'")