Changing file metadata in Python

Well, I searched here, but did not find anything indicating a solid answer.

I am trying to change the file, file name, rating, genre, etc. in the windows that appears when viewing folders in the "details".

At the moment, I have files that I want to edit in the list, and I repeat them, but, as I said, I'm not sure how to change it for each file in the list.

def Files(The_FileList):
'''Changes each files metadata'''
for each_file in The_FileList:

    #clueless here.

return The_FileList

it is necessary to work with .avi / .mkv files in a general way, since I code a lot.

I am looking for a simple option, as that is all I want to do.

thank

+4
source share
2 answers

( ) . ( , NTFS , , ).

, , , Mutagen ( , mp3/aac/flac/vorbis/etc. - , , ).

+5

.

3 :

import mutagen
from mutagen.mp4 import MP4
from os import scandir

ruta = './'
l_archivos = sorted([archivo.name for archivo in scandir(ruta) if archivo.is_file()])

mutagen.File(l_archivos[1])      # U: See the tags of the data

def edit_Media_Data():

    for f in range(len(l_archivos[:-1])):                 # A: A range of all the fields exept the script
        file = MP4(l_archivos[f])                         # A: Capture the file to edit
        file['©nam'] = l_archivos[f].replace('.mp4','')   # U: Take the file name and makeit the tittle
        file['©ART'] = 'Hector_Costa_Guzman'              # U: Edit the Autor
        file['©alb'] = 'Curso_Django'                     # U: Edit the Album
        file.pprint()
        file.save()  
0

Source: https://habr.com/ru/post/1750939/


All Articles