-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpdfmetadata-gui
More file actions
executable file
·39 lines (33 loc) · 1.09 KB
/
Copy pathpdfmetadata-gui
File metadata and controls
executable file
·39 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
title=$(pdfinfo "$1" | grep "Title" | awk '{sub(/[^ ]+ /, ""); print $0}' | sed 's/^[ \t]*//;s/[ \t]*$//')
author=$(pdfinfo "$1" | grep "Author" | awk '{sub(/[^ ]+ /, ""); print $0}' | sed 's/^[ \t]*//;s/[ \t]*$//')
values=$(yad \
--center \
--selectable-labels \
--form \
--text="The changes are made to this file:\n$1" \
--text-align=center \
--columns=2 \
--class="pdfmetadata-gui" \
--name="PDF Metadata GUI" \
--title="$(basename "$0") - $1" \
--center \
--width=400 \
--separator="~/~" \
--field=Title \
"$title" \
--field=Author \
"$author" \
--field="Update":CHK \
"TRUE" \
--field="Update":CHK \
"TRUE" \
)
[[ -z "$values" ]] && exit 1
newTitle=$(echo "$values" | awk -F "~/~" '{print $1}')
newAuthor=$(echo "$values" | awk -F "~/~" '{print $2}')
updateTitle=$(echo "$values" | awk -F "~/~" '{print $3}')
updateAuthor=$(echo "$values" | awk -F "~/~" '{print $4}')
[[ $updateTitle == "TRUE" ]] && exiftool -overwrite_original -Title="$newTitle" "$1"
[[ $updateAuthor == "TRUE" ]] && exiftool -overwrite_original -Author="$newAuthor" "$1"
exit 0