1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 22:42:41 +00:00

subdirs in --name-format

This commit is contained in:
fiso64 2024-01-02 12:00:37 +01:00
parent c91feea0ba
commit 64c65ee687
2 changed files with 11 additions and 6 deletions

View file

@ -2251,10 +2251,10 @@ static class Program
if (format.Contains("{title}") && string.IsNullOrEmpty(file.Tag.Title)) if (format.Contains("{title}") && string.IsNullOrEmpty(file.Tag.Title))
return filepath; return filepath;
newName = newName.Replace("{artist}", file.Tag.FirstPerformer ?? "") newName = newName.Replace("{artist}", (file.Tag.FirstPerformer ?? "").RemoveFt())
.Replace("{artists}", string.Join(" & ", file.Tag.Performers)) .Replace("{artists}", string.Join(" & ", file.Tag.Performers).RemoveFt())
.Replace("{album_artist}", file.Tag.FirstAlbumArtist ?? "") .Replace("{album_artist}", (file.Tag.FirstAlbumArtist ?? "").RemoveFt())
.Replace("{album_artists}", string.Join(" & ", file.Tag.AlbumArtists)) .Replace("{album_artists}", string.Join(" & ", file.Tag.AlbumArtists).RemoveFt())
.Replace("{title}", file.Tag.Title ?? "") .Replace("{title}", file.Tag.Title ?? "")
.Replace("{album}", file.Tag.Album ?? "") .Replace("{album}", file.Tag.Album ?? "")
.Replace("{year}", file.Tag.Year.ToString() ?? "") .Replace("{year}", file.Tag.Year.ToString() ?? "")
@ -2264,8 +2264,13 @@ static class Program
if (newName != format) if (newName != format)
{ {
string directory = Path.GetDirectoryName(filepath); string directory = Path.GetDirectoryName(filepath);
string dirsep = Path.DirectorySeparatorChar.ToString();
string extension = Path.GetExtension(filepath); string extension = Path.GetExtension(filepath);
string newFilePath = Path.Combine(directory, ReplaceInvalidChars(newName, " ") + extension); newName = newName.Replace(new string[] { "/", "\\" }, dirsep);
var x = newName.Split(dirsep, StringSplitOptions.RemoveEmptyEntries);
newName = string.Join(dirsep, x.Select(x => ReplaceInvalidChars(x, " ")));
string newFilePath = Path.Combine(directory, newName + extension);
System.IO.Directory.CreateDirectory(Path.GetDirectoryName(newFilePath));
System.IO.File.Move(filepath, newFilePath); System.IO.File.Move(filepath, newFilePath);
return newFilePath; return newFilePath;
} }

View file

@ -25,7 +25,7 @@
<PackageReference Include="SpotifyAPI.Web" Version="7.0.2" /> <PackageReference Include="SpotifyAPI.Web" Version="7.0.2" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.0.2" /> <PackageReference Include="SpotifyAPI.Web.Auth" Version="7.0.2" />
<PackageReference Include="TagLibSharp" Version="2.3.0" /> <PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="YoutubeExplode" Version="6.3.9" /> <PackageReference Include="YoutubeExplode" Version="6.3.10" />
</ItemGroup> </ItemGroup>
</Project> </Project>