News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Rename to '.jpg' if filetype isn't PNG

Started by xify, June 09, 2021, 03:58:17 AM

Previous topic - Next topic

xify

Hi,

I exported Google Photos using Google Takeout, and am now trying to clean up the files before importing them into the Photos app on macOS.

There are some JPG files that appear to have an incorrect file name ending in '.png'

I want to rename the 'PNG' image files and the corresponding json files and their tags.


ExifTool Version Number         : 12.26
File Name                       : IMG_6893.PNG
Directory                       : .
File Size                       : 82 KiB
File Modification Date/Time     : 2021:06:05 04:13:52+10:00
File Access Date/Time           : 2021:06:09 16:32:15+10:00
File Inode Change Date/Time     : 2021:06:09 16:05:21+10:00
File Permissions                : -rw-rw-r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Orientation                     : Horizontal (normal)
X Resolution                    : 216
Y Resolution                    : 216
Resolution Unit                 : inches
Software                        : Picasa
Exif Version                    : 0220
Exif Image Width                : 1099
Exif Image Height               : 1235
Image Unique ID                 : 3fb4a52c7d6d56200000000000000000
Compression                     : JPEG (old-style)
Thumbnail Offset                : 334
Thumbnail Length                : 8482
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2017:07:07 13:22:32
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    :
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Apple Computer Inc.
Profile ID                      : ca1a9582257f104d389913d5d1ea1582
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2017
Media White Point               : 0.95045 1 1.08905
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
Current IPTC Digest             : d41d8cd98f00b204e9800998ecf8427e
IPTC Digest                     : d41d8cd98f00b204e9800998ecf8427e
Image Width                     : 1099
Image Height                    : 1235
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 1099x1235
Megapixels                      : 1.4
Thumbnail Image                 : (Binary data 8482 bytes, use -b option to extract)



ExifTool Version Number         : 12.26
File Name                       : IMG_6893.PNG.json
Directory                       : .
File Size                       : 794 bytes
File Modification Date/Time     : 2021:06:05 04:16:20+10:00
File Access Date/Time           : 2021:06:09 16:38:48+10:00
File Inode Change Date/Time     : 2021:06:09 16:05:23+10:00
File Permissions                : -rw-rw-r--
File Type                       : JSON
File Type Extension             : json
MIME Type                       : application/json
Creation Time Formatted         : Feb 9, 2021, 6:15:48 AM UTC
Creation Time Timestamp         : 1612851348
Description                     :
Geo Data Altitude               : 0.0
Geo Data Latitude               : 0.0
Geo Data Latitude Span          : 0.0
Geo Data Longitude              : 0.0
Geo Data Longitude Span         : 0.0
Geo Data Exif Altitude          : 0.0
Geo Data Exif Latitude          : 0.0
Geo Data Exif Latitude Span     : 0.0
Geo Data Exif Longitude         : 0.0
Geo Data Exif Longitude Span    : 0.0
Google Photos Origin Mobile Upload Device Type: IOS_PHONE
Image Views                     : 16
Photo Taken Time Formatted      : Feb 9, 2021, 6:08:14 AM UTC
Photo Taken Time Timestamp      : 1612850894
Title                           : IMG_6893.PNG


The '.PNG' files should be renamed to '.jpg'
'PNG.json' file names should be renamed to 'jpg.json' and the 'Title' tags should also be '.jpg'.

I'm not sure the command I need to use. Any help would be appreciated.

Thank you.

Phil Harvey

Are all of the PNG files like this, or are some really PNG format?

If they are all like this, it is easy:

exiftool "-filename<${filename;s/\bPNG\b/jpg/}" "-title<${title;s/\bPNG\b/jpg/}" -ext png -ext json DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Late to the thread, but the Title tag is only appearing in the JSON file and exiftool cannot edit json files.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).