[FFmpeg-devel] [RFC][PATCH] Tool to sort files a bit

Rodney Baker rodney.baker
Sat Oct 9 03:14:00 CEST 2010


On Sat, 9 Oct 2010 08:42:17 Michael Niedermayer wrote:
> Hi
> 
> The attached script creates directories and symlinks for multimedia files
> based on container and codec in the file. I hope ive not done this work
> redundantly
> it needs to be checked by someone who knows shell escaping to make it
> secure ive made no attempt at making it secure.
> 
> Also if people are ok with it id like to commit this so more people can
> work on it, iam not an expert on shell programming ...
> 
> yes its intended to help with incoming / samples maybe at some point or
> even to help people sort their personal file collections
> 
> 
> commit ca9a964c2eba0ba6cda767cfe2d74b80c245dd4c
> Author: Michael Niedermayer <michaelni at gmx.at>
> Date:   Fri Oct 8 23:58:51 2010 +0200
> 
>     Tool to analyze multimedia files and create directories and symlinks
> for the container type and codecs in each file that point back to the
> file.
> 
> diff --git a/tools/jauche_sortierer.sh b/tools/jauche_sortierer.sh

Should the filename be in English (to be consistent with the chosen language 
of ffmpeg as a whole)?

> new file mode 100755
> index 0000000..517353f
> --- /dev/null
> +++ b/tools/jauche_sortierer.sh
> @@ -0,0 +1,19 @@
> +#!/bin/sh
> +#GPL
> +#TODO
> +#add pixelformat/sampleformat into the path of the codecs
> +
> +FFP=../ffprobe
> +TMP=./misthaufen

Nit: I'm guessing that this German-named directory exists on the target 
server; perhaps a comment that this directory needs to be renamed to something 
that exists on the users' target machine if this is to be used elsewhere might 
be good.

> +TARGET=$1
> +shift
> +
> +for v do
> +    BASE=`basename $v`
> +    echo $v | egrep -i '(public|private)' >/dev/null && echo Warning $v
> may be private +    $FFP $v 2> $TMP
> +    FORM=`(grep 'Input #0, ' -m1 $TMP || echo 'Input #0, unknown') | sed
> 's/Input #0, \([a-zA-Z0-9_]*\).*/\1/' ` +    mkdir -p
> $TARGET/container/$FORM
> +    ln -s $v $TARGET/container/$FORM/$BASE
> +    eval `grep 'Stream #0\.[^:]*: [a-zA-Z0-9][^:]*: [a-zA-Z0-9]' $TMP |
> sed 's#[^:]*: \([a-zA-Z0-9]*\)[^:]*: \([a-zA-Z0-9]*\).*#mkdir -p
> '$TARGET'/\1/\2 ; ln -s '$v' '$TARGET'/\1/\2/'$BASE' ; #'` +done

Long line - can be split using the line continuation character "  \ "

I'll leave the rest to someone who better understands regex's and sed.

-- 
===================================================
Rodney Baker VK5ZTV
rodney.baker at iinet.net.au
=================================================== 




More information about the ffmpeg-devel mailing list