Project

General

Profile

RE: "Pulling out" the value of one IPTC tag? ยป fife.sh

Steve Wright, 05 Feb 2010 20:18

 
1
#!/bin/bash
2
IFS=$'\t\n'
3

    
4
function runmyfile {
5
	oldf1=$(exiv2 -PInv $gfile | grep 'FixtureId' | sed 's/^FixtureId[       ]*//')
6
	fixold=$oldf1
7
	echo -e "The word or phrase currently in this file reads:\n\t \033[4;37m${oldf1}\033[0m."
8
	echo -ne "\033[0;36mDo you want to change this Fixture ID to something else? \033[0m (y/n)\n"
9
	read yesorno
10
	if [ $yesorno = "n"  ]
11
	then
12
		echo -ne "No changes made to file \033[1;34m${gfile}.\033[0m\nBye.\n"
13
	else
14
		echo -ne "\033[1;31mAre you sure?\033[0m (y/n) \n"
15
		read confirmm
16
		if [ $confirmm = "n" ]
17
		then
18
		echo -ne "No changes made to file \033[1;34m${gfile}.\033[0m\nBye.\n"
19
		else
20
			exiv2 -M"del Iptc.Application2.FixtureId" modify $gfile
21
			echo -ne "FIXTURE IDENTIFICATION HAS BEEN REMOVED.\n"
22
			echo -ne "Please enter the word or phrase to replace '$fixold .'\n"
23
			read newstringhx 
24
			capnew="`echo ${newstringhx} | awk '{print toupper($0)}'`"
25
			exiv2 -M"add Iptc.Application2.FixtureId String $newstringhx" modify $gfile
26
			sleep 0.5
27
			filecapper="`echo ${gfile} | awk '{print toupper($0)}'`"
28
			echo -ne "FIXTURE IDENTIFICATION \"$capnew\" WRITTEN TO FILE ${filecapper}.\n"
29
			echo -ne "(Don't worry -- it was written the way you wrote it.)\n"
30
		fi
31
	fi
32
}
33

    
34

    
35
echo -ne "Fixture Identification Fixer for Exiv2 - FIFE\n"
36
echo -ne "Please enter the name of the file you want to modify.\n"
37
read 'gfile'
38
if [ -f $gfile ]
39
then
40
	runmyfile
41
else
42
	echo -e "Sorry, that file is not in this folder.\n"
43
	echo -e "Let me take another look.\n"
44
	maybe=(`find . -name "*$gfile*" | cut -d / -f2`)
45
	sleep 1.5
46
	echo -ne "Do you mean: $maybe ? (y/n) \n"
47
	#Using a variable one can be sure has no built-in value in BASH:
48
	read cheeseburger
49
	if [ ["$cheeseburger" == "n"] ]
50
	then
51
		echo -ne "\033[0;34mWell, I tried.\033[0m\n"
52
	else
53
		gfile=$maybe
54
		runmyfile
55
	fi
56
fi
    (1-1/1)