Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem Jak do excelu vložit názvy souborů?

Zdravím. Mám složku Narozeninovka na ploše a v ní mám písničky. Chci ovšem tento seznam písniček hodit do excelu - aspoň jejich názvy (nejlépe i délku). Jak to udělat? Jak přenést každý název ze složky do excelu tak, abych to nemusel přepisovat ručně?

Předem děkuji za odpovědi.

Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
Nebo můžeš použít utilitu napsanou v C# před chvilkou - tzn. není moc otestovaná ;) Použití: Sezna…
ws79 13.07.2016 14:48
ws79
Lol, to je hrozná pakárna to céčko. Přtom stačí jeden příkaz a výsledek je stejný.
111 13.07.2016 14:52
111
Jo, a jak v z DIRu vypíšeš případně ID3 tagy ;). Navíc pokud jsou ve složce i jiné soubory než MP3,… nový
ws79 13.07.2016 15:08
ws79
Pardon, neměl jsem na mysli zrovna tenhle příkaz. Proč by to nemělo fungovat n jiné soubory nechápu,… nový
111 13.07.2016 15:13
111
No, občas se u písniček ukládá i obrázek s obalem od alba... Tak ukaž příkaz, který vypíše i ID3 tag… nový
ws79 13.07.2016 15:19
ws79
No na Linuxu bych to řešil přes mp3info. mp3info -h MP3Info 0.8.5a Copyright (C) 2006 Cedric Tefft… poslední
111 13.07.2016 15:37
111

Nebo můžeš použít utilitu napsanou v C# před chvilkou - tzn. není moc otestovaná ;)

Použití:

SeznamPisnicek.exe -file c:\temp\SouborSeSeznamem.xlsx -folder C:\MP3

Src:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OfficeOpenXml;
using NDesk.Options;

namespace SeznamPisnicek
{
    class Program
    {
        private static readonly List<TagLib.File> Files = new List<TagLib.File>();

        private static void Main(string[] args)
        {
            string folder = null;
            string fn = null;

            var p = new OptionSet()
            {
                {"folder=", v => folder = v},
                {"file=", v => fn = v},
            };
            p.Parse(args);

            if (string.IsNullOrEmpty(folder) || string.IsNullOrEmpty(fn))
            {
                Console.WriteLine("Neplatný název složky nebo souboru!");
                return;    
            }

            GetFiles(folder,fn);
        }

        private static void GetFiles(string folder, string fn)
        {
            var di = new DirectoryInfo(folder);

            foreach (var file in  di.GetFiles("*.mp3"))
            {
                try
                {
                    Files.Add(TagLib.File.Create(file.FullName));
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            CreateExcel(fn);
        }

        private static void CreateExcel(string fn)
        {
            var fileName = new FileInfo(fn); 

            if (fileName.Exists) fileName.Delete();

            using (var ex = new ExcelPackage(fileName))
            {
                var ws = ex.Workbook.Worksheets.Add("Seznam písniček");

                ws.Cells[1, 1].Value = "Název souboru";
                ws.Cells[1, 2].Value = "Název - ID3 tag Title";
                ws.Cells[1, 3].Value = "Délka";

                var y = 1;
                foreach (var file in Files)
                {
                    ws.Cells[y + 1, 1].Value = file.Name.Split('\\').Last();
                    ws.Cells[y + 1, 2].Value = file.Tag.Title;
                    ws.Cells[y + 1, 3].Value = file.Properties.Duration.Hours > 0 ? $"{file.Properties.Duration.Hours}:{file.Properties.Duration.Minutes:00}:{file.Properties.Duration.Seconds:00}"
                                                                                                                      : $"{file.Properties.Duration.Minutes}:{file.Properties.Duration.Seconds:00}";

                    y++;
                }

                ws.Column(1).AutoFit();
                ws.Column(2).AutoFit();
                ws.Column(3).AutoFit();

                ex.Save();
            }
        }
    }
}

No na Linuxu bych to řešil přes mp3info.

mp3info -h
MP3Info 0.8.5a Copyright (C) 2006 Cedric Tefft and Ricardo Cerqueira

USAGE:

	mp3info [ -h | -G ]

	mp3info [-x] [-F] [-r a|m|v] [-p FORMAT_STRING] file(s)

	mp3info [-d] file(s)

	mp3info [-i]  [-t title] [-a artist] [-l album] [-y year]
		[-c comment] [-n track] [-g genre] file(s)

OPTIONS
	-a artist	Specify ID3 artist name
	-c comment	Specify ID3 comment
	-g genre	Specify ID3 genre (use -G for genre list)
	-l album	Specify ID3 album name
	-n track	Specify ID3 v1.1 track number
	-t title	Specify ID3 track title
	-y year		Specify ID3 copyright year

	-G		Display valid genres
	-h		Display this help page
	-x		Display technical attributes of the MP3 file
	-r a|m|v	Report bit rate of (VBR) files as:
		a - Average bit rate (float)
		m - Median bit rate (integer)
		v - Simply  use  the  word 'Variable' (string) [default]

	-i		Edit ID3  tag  interactively
	-d		Delete ID3 tag (if one exists)
	-f		Force processing if file is not a standard MP3
	-F		Full Scan (see man page for details)


	-p "FORMAT_STRING" Print FORMAT_STRING with substitutions

		Conversion Specifiers

		%f	Filename without the path (string)
		%F	Filename with the path (string)
		%k	File size in KB (integer)

		%a	Artist (string)
		%c	Comment (string)
		%g	Musical genre (string)
		%G	Musical genre (integer)
		%l	Album name (string)
		%n	Track (integer)
		%t	Track Title (string)
		%y	Year (string)

		%C	Copyright flag (string)
		%e	Emphasis (string)
		%E	CRC Error protection (string)
		%L	MPEG Layer (string)
		%O	Original material flag (string)
		%o	Stereo/mono mode (string)
		%p	Padding (string)
		%v	MPEG Version (float)

		%u	Number of good audio frames (integer)
		%b	Number of corrupt audio frames (integer)
		%Q	Sampling frequency in Hz (integer)
		%q	Sampling frequency in kHz (integer)
		%r	Bit  Rate  in  kbps  (see also '-r')

		%m	Playing time: minutes only (integer)
		%s	Playing time: seconds only (integer)
		%S	Total playing time in seconds (integer)

		%%	A single percent sign

		Escape Sequences

		\n	Newline
		\t	Horizontal tab
		\v	Vertical tab
		\b	Backspace
		\r	Carriage Return
		\f	Form Feed
		\a	Audible Alert (terminal bell)
		\xhh	Any  arbitrary character specified by the
			hexidecimal number hh
		\ooo	Any arbitrary character specified by  the
			octal number ooo
		\\	A single backslash character

This help screen is only a summary of command-line switches

Zpět do poradny Odpovědět na původní otázku Nahoru