3

I want to extract multiple information using grep. example:

when using exiftool, I got all this information, and more:

$exiftool Titanic.Avi

ExifTool Version Number         : 8.60
File Name                       : Titanic.Avi
Directory                       : .
File Size                       : 702 MB
File Modification Date/Time     : 2013:07:28 22:36:46+02:00
File Permissions                : rw-rw-r--
File Type                       : AVI
  1. I want to view only the File Name and the File Type.

like this:

File Name                       : Titanic.Avi
File Type                       : AVI

I have a Directory Movie, and containing a hole directories, in each directory there is a movie, i want to extract those information from it

example:

Movies\Titanic\Titanic.avi
Movies\The Call\The Call.avi
.
.
Movies\Pawn\Pawn.mkv
  1. I need a loop with exiftool and | grep to get info like this:

Titanic.avi

File Name                       : Titanic.Avi
File Type                       : AVI

The Call.avi

    File Name                       : The Call.Avi
    File Type                       : AVI

Pawn.mkv

    File Name                       : Pawn.Avi
    File Type                       : MKV
4

2 回答 2

2

只是

function identify()
{
    for fname in "$@"
    do
        while read line
        do
           echo "$fname $line"
        done < <(exiftool "$1"|egrep 'File Type|File Name')
    done
}

现在你可以

identify *.mkv *.avi

(注意未经测试:我没有这些工具或任何可用的示例文件)更新。刚刚通过制作一个虚拟助手进行了测试

function exiftool() { echo File Type 5; echo 42 File Name; }
identify *

如果您想在一行中获取文件的所有信息,您可以添加xargs

exiftool "$1"|egrep 'File Type|File Name' | xargs
于 2013-07-30T13:35:49.277 回答
0

看看 mediainfo,你可以直接使用它来获取特定的元数据。

mediainfo --Inform='General;%CompleteName% - %Format%' Du.Plo*    

=> Du.Plomb.Dans.La.Tete.2012.VOSTFR.REPACK.720p.BluRay.x264-Felony.mkv - Matroska
于 2013-07-30T16:10:24.393 回答