kitab

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | LICENSE

set.sh (961B)


      1 #!/bin/bash
      2 
      3 f=$1
      4 
      5 if [ ! -f "$f" ]; then
      6 	>&2 echo $f is not a file
      7 	exit 1
      8 fi
      9 
     10 echo -n "Title: "
     11 read title
     12 if [ ! -z "$title" ]; then
     13 	setfattr -n user.dcterms:title -v "$title" "$f"
     14 fi
     15 
     16 getfattr -n user.dcterms:title "$f" &> /dev/null
     17 if [ "$?" -gt "0" ]; then
     18 	>&2 echo no title set, exiting.
     19 	exit 0
     20 fi
     21 
     22 echo -n "Author: "
     23 read author
     24 if [ ! -z "$author" ]; then
     25 	setfattr -n user.dcterms:creator -v "$author" "$f"
     26 fi
     27 
     28 echo -n "Subject (comma,separated list): "
     29 read subject
     30 if [ ! -z "$subject" ]; then
     31 	setfattr -n user.dcterms:subject -v "$subject" "$f"
     32 fi
     33 
     34 echo -n "Language: "
     35 read language
     36 if [ ! -z "$language" ]; then
     37 	setfattr -n user.dcterms:language -v "$language" "$f"
     38 fi
     39 
     40 echo -n "Type: "
     41 read typ
     42 if [ ! -z "$typ" ]; then
     43 	setfattr -n user.dcterms:type -v "$typ" "$f"
     44 fi
     45 
     46 mime=`file -b --mime-type "$f"`
     47 echo -n "Mime ($mime): "
     48 read mime_in
     49 if [ ! -z "$mime_in" ]; then
     50 	mime=$mime_in
     51 fi 
     52 setfattr -n user.dcterms:MediaType -v "$mime" "$f"