Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a script using Exiftool to remove the software tag, comment header line and date data (in both EXIF and IPTC) from files saved with Gimp 2.8 or 2.9. I want to simplify it so the user needn't go any further than to type the name of the script and the name of the file they want to strip.
The script is called degimp.
Code follows.
Code:
#!/bin/bash -i
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo -e "What file do you want to 'De-GIMP'?"
read -e item
file1=$item
if [ -f "$file1" ]; then
exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $file1
echo "File $file1 is now De-GIMPed."
echo "Check it for yourself with any good tool."
else
echo "Your file is not in this directory."
echo "No file to de-GIMP."
exit 0
fi
IFS=$SAVEIFS
I'm still a little sketchy w/re the whole "$1" thing. Would a line at the top like
Distribution: Slackware (current), Slack15, win10 that is just there beacuse I have a copy of it
Posts: 10,084
Rep:
Code:
$./FileName argument argument
$0 $1 $2
build in Bash assignments for variables.
Code:
Removed this line #!/bin/bash -i, <- I do not know what that -i is for,
but it kept restarting my shell,
so I replaced with this
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
#echo -e "What file do you want to 'De-GIMP'?"
#read -e item
echo "$0"
echo "$1"
#file1="item"
if [ -f "$1" ]; then
# exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $1
echo "File $1 is now De-GIMPed."
echo "Check it for yourself with any good tool."
else
echo "Your file is not in this directory."
echo "No file to de-GIMP."
exit 0
fi
IFS=$SAVEIFS
just type in the script name and then file name hit enter.
Code:
userx@voided1.what~>> ./xtest textCattwo
./xtest
textCattwo
File textCattwo is now De-GIMPed.
Check it for yourself with any good tool.
#!/bin/bash
[[ -f $1 ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $$(date +%F).$1 && echo -e "File $file1 is now De-GIMPed.\nCheck it for yourself with any good tool."; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
Distribution: Slackware (current), Slack15, win10 that is just there beacuse I have a copy of it
Posts: 10,084
Rep:
if you want to do more error checking, say for the proper file type.
Code:
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo "$0"
echo "$1"
c=$1
ext=${c##*.}
echo "ext $ext"
if [[ -f "$1" && "$ext" == 'mp4' || "$ext" == 'mkv' ]]; then
# exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $file1
echo "File $1 is now De-GIMPed."
echo "Check it for yourself with any good tool."
else
echo "Your file is not in this directory."
echo "No file to de-GIMP."
exit 1 <- error is not exit 0
fi
#IFS=$SAVEIFS
if it is the wrong extension then it gets error'ed out.
Code:
userx@voided1.what~>> ./xtest textCattwo.oop
./xtest
textCattwo.oop
ext oop
Your file is not in this directory.
No file to de-GIMP.
Distribution: Slackware (current), Slack15, win10 that is just there beacuse I have a copy of it
Posts: 10,084
Rep:
@c0wb0y
I had to fix your code, I just added mine to yours before checking yours.
Code:
userx@voided1.what~>> ./xtest textCattwo.mkv
./xtest
textCattwo.mkv
ext mkv
./xtest: line 20: syntax error near unexpected token `('
./xtest: line 20: `[[ -f $1 && "$ext" == 'mp4' || "$ext" == 'mkv' ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $$(date +%F).$1 && echo -e "File $file1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."'
Code:
#!/bin/bash
#-i
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
c=$1
ext=${c##*.}
echo "ext $ext"
[[ -f $1 && "$ext" == 'mp4' || "$ext" == 'mkv' ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $(date +%F).$1 && echo -e "File $file1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
IFS=$SAVEIFS
Distribution: Slackware (current), Slack15, win10 that is just there beacuse I have a copy of it
Posts: 10,084
Rep:
Quote:
Originally Posted by c0wb0y
I know. Those damn extra double quotes and $ sign. These fat fingers.
I fix that then ran it and it still throws an error, so I fixed that and I am not sure what type of files he is using. but that Date I did not fix. getting this error
Code:
userx@voided1.what~>> ./xtest Pitch.Perfect.2.2015.720p.mp4
ext mp4
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in IFD0:ModifyDate (PrintConvInv)
Error: Truncated mdat atom - Pitch.Perfect.2.2015.720p.mp4
Your file is not in this directory.
No file to de-GIMP.
using this code.
Code:
#!/bin/bash
#-i
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
c=$1
ext=${c##*.}
echo "ext $ext"
#[[ -f $1 && "$ext" == 'mp4' || "$ext" == 'mkv' ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $(date +%F).$1 && echo -e "File $file1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
#### this one
[[ -f $1 ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate="$(date +%F)" $1 && echo -e "File $file1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
IFS=$SAVEIFS
Just a date format issue NBD, I changed it to this
Code:
-ModifyDate="$(date +%F%T)" $1 <-- exiftool needs file name last to process it.
removing the filename because it kept looking for the annotated file and not the one added on the command line.
Code:
userx@voided1.what~>> ./xtest Pitch.Perfect.2.2015.720p.mp4
ext mp4
Error: File not found - 2016-12-10.Pitch.Perfect.2.2015.720p.mp4
Error: Truncated mdat atom - Pitch.Perfect.2.2015.720p.mp4
Your file is not in this directory.
No file to de-GIMP.
I do not know what type of file he is actually working with, but just using this line(s)
Code:
#!/bin/bash
#-i
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
c=$1
ext=${c##*.}
echo "ext $ext"
[[ -f $1 && "$ext" == 'mp4' || "$ext" == 'mkv' ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate="$(date +%F%T)" $1 && echo -e "File $1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
#[[ -f $1 ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate="$(date +%F%T)" $1 && echo -e "File $file1 is now De-GIMPed.\n"Check it for yourself with any good tool.""; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
IFS=$SAVEIFS
keeping in that error checking for extensions type with and without it I still get the same error.
Code:
userx@voided1.what~>> ./xtest Pitch.Perfect.2.2015.720p.mp4
ext mp4
Error: Truncated mdat atom - Pitch.Perfect.2.2015.720p.mp4
Your file is not in this directory.
No file to de-GIMP.
so it kicks it out and sends the last message.
now if he, the OP can figure all of this out, that'd be a good thing.
After a little more Google-ing and getting friendly with Stack Exchange, I came up with this re-edit of my original script:
Code:
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
file1="$1"
if [ -f "$file1" ]; then
exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $file1
echo "File $file1 is now De-GIMPed."
echo "Check it for yourself with any good tool."
else
echo ""
echo "No file to de-GIMP."
exit 0
fi
IFS=$SAVEIFS
Tested it six times already. No errors (a surprise) and the tags are indeed removed.
I have yet to test the Your file is not in this directory. Which seems unnecessary since the user is naming the file to be de-gimp'ed. I may just edit it out. That sort of thing fits better with a "while read line" kind of loop, which was what I was trying to get away from.
I kept the original script in my execution path, of course and renamed it degimp2. degimp seems more appropriate for the one where the filename follows the command to start the script. I was surprised to not get any bash error messages. I guess the changes I made were up to spec for bash 4.3.
Carver
Last edited by L_Carver; 12-10-2016 at 08:47 PM.
Reason: Flow of sentences; spelling,
Hah! Problem with me writing on-the-fly and not reading what those arguments for.
Code:
#!/bin/bash
[[ -f $1 ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $1 && echo -e "File $file1 is now De-GIMPed.\nCheck it for yourself with any good tool."; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
Distribution: Slackware (current), Slack15, win10 that is just there beacuse I have a copy of it
Posts: 10,084
Rep:
Quote:
Originally Posted by c0wb0y
Hah! Problem with me writing on-the-fly and not reading what those arguments for.
Code:
#!/bin/bash
[[ -f $1 ]] && { exiftool -fast5 -overwrite_original_in_place -P -q -Software= -Comment= -IPTC:DateCreated= -IPTC:TimeCreated= -ModifyDate= $1 && echo -e "File $file1 is now De-GIMPed.\nCheck it for yourself with any good tool."; } || echo -e "Your file is not in this directory.\nNo file to de-GIMP."
I think he wanted to make everything void and null .. anyways, he went to another store to get what he needed after asking us.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.