-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatGPT.sh
83 lines (70 loc) · 2.13 KB
/
chatGPT.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Display a menu for passing arguments to qpdf
args=$(yad --form --separator='' \
--field='Input File:FL' \
--field='Output File:FL' \
--field='Password:H' \
--field='Encryption Algorithm:CB' 'AES-128' 'AES-256' 'None' \
--field='Encrypt Metadata:CHK' \
--field='Compress Streams:CHK' \
--field='Linearize:CHK' \
--field='Additional Options:TXT' \
--title='qpdf Options' --width=500 --height=300)
# Split the arguments into an array
IFS='|' read -ra arg_array <<< "$args"
# Set variables for each argument
input_file=${arg_array[0]}
output_file=${arg_array[1]}
password=${arg_array[2]}
encryption_algorithm=${arg_array[3]}
encrypt_metadata=${arg_array[4]}
compress_streams=${arg_array[5]}
linearize=${arg_array[6]}
additional_options=${arg_array[7]}
# Build the qpdf command
command="qpdf"
if [ ! -f "$input_file" ]; then
yad --error --text="Error: Input file not found"
exit 1
fi
# Add the input file argument
if [ ! -z "$input_file" ]; then
command="$command --input-file $input_file"
fi
if [ -f "$output_file" ]; then
confirm=$(yad --question --text="Output file already exists. Overwrite?")
if [ "$confirm" != "0" ]; then
exit 0
fi
fi
# Add the output file argument
if [ ! -z "$output_file" ]; then
command="$command --output-file $output_file"
fi
# Add the password argument
if [ ! -z "$password" ]; then
command="$command --encrypt $password $password"
fi
# Add the encryption algorithm argument
if [ "$encryption_algorithm" != "None" ]; then
command="$command --encrypt-metadata=n $encryption_algorithm"
fi
# Add the encrypt metadata argument
if [ "$encrypt_metadata" = "TRUE" ]; then
command="$command --encrypt-metadata=y"
fi
# Add the compress streams argument
if [ "$compress_streams" = "TRUE" ]; then
command="$command --compress-streams"
fi
# Add the linearize argument
if [ "$linearize" = "TRUE" ]; then
command="$command --linearize"
fi
# Add any additional options
if [ ! -z "$additional_options" ]; then
command="$command $additional_options"
fi
# Execute the qpdf command
$command
trap 'yad --error --text="Error: qpdf command failed" >&2' ERR