Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear all tags then tag from filename/path and/or rename/class from tags #5

Open
CyberSinh opened this issue Feb 15, 2018 · 0 comments
Labels

Comments

@CyberSinh
Copy link
Member

CyberSinh commented Feb 15, 2018

// Clear all tags then tag from filename/path and/or rename/class from tags

using Metatogger.Business;
using Metatogger.Data;

foreach (var file in files)
{	
	// 1. Supprime tous les tags
	foreach (var tag in file.GetAllTags())
	   file.SetTag(tag.Key, null);
			
	// 2.1 Récupère le nom de l'artiste et du titre du morceau depuis le nom de fichier
	var tags = TagProcessor.TagFromFilename("|artist| - |title|", file);

        // 2.2 Récupère le nom de l'artiste et du titre du morceau depuis le chemin du fichier
	var tags2 = TagProcessor.TagFromPath(@"|artist|\|album|", file);        
	
	// 3. Copie le nom de l'artiste récupéré depuis le nom du fichier dans le tag ARTIST et ORIGINALARTIST
	if (tags.ContainsKey(TagName.Artist))
	{
	   string artist = tags[TagName.Artist][0];
	   file.SetTag(TagName.Artist, artist);
	   file.SetTag(TagName.OriginalArtist, artist);
	}
	
	// 4. Copie le titre de l'album récupéré dans le tag ALBUM
	if (tags2.ContainsKey(TagName.Album))
           file.SetTag(TagName.Album, tags2[TagName.Album][0]);

        // 5.1 Nouveau nom de fichier basé sur les tags
        string newFilename = TagProcessor.RenameFromTags("<|artist| - ><[|album| #|tracknumber|] >|title|", file);
        if (newFilename != null)
           file.OutputFilename = newFilename ;

        // 5.2 Nouveau chemin basé sur les tags
        string newPath = TagProcessor.PathFromTags(@"%MYMUSIC%\|codec|\|artist|\<|date| - >|album|", file);
        if (newPath != null)
        {
           file.OutputPath = newPath ;
           file.FileProcess = FileProcess.Move; // FileProcess.Copy / FileProcess.SoftLink
        }
}
@CyberSinh CyberSinh changed the title Clear all tags then tag from filename Clear all tags then tag from filename/path and/or rename/class from tags Sep 11, 2019
@luminescence-software luminescence-software locked and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant