Author Topic: Renaming files  (Read 269 times)

wk002

  • Newbie
  • *
  • Posts: 7
Renaming files
« on: January 15, 2019, 03:58:10 PM »
I have to say to all who have helped develop this tool that you all Rock!

With that said I am trying to rename all files in ~/Photos to "~/Pictures/CameraManufacture_CameraModel_ISO_ShutterSpeed_apature_resolution_%Y%m%d_%H%M%S-%%c.%%e and organize all the files into a directory based on date YYYY/MM/DD

This is what I have so far, I think I am doing everything I need except the camera and exposure settings.

exiftool -d ~/Pictures/%Y/%m/%d/%Y%m%d_%H%M%S%%-c.%%e "-filename<DateTimeOriginal" ~/Photos

In case anyone is wondering why all the info in the file name it's because over the last fifteen years I have somehow managed to make duplicates that are missing exif data. So the files are not identical. I can't use a scanning tool to delete the duplicates. I should have probably 20K worth of photos but instead I have something like 90K photos spanning 15 years. I am hoping that if I can rename them then I can sort by file name and move photos with missing data to one folder and what I am hoping are the originals to the second folder. Then I can do some comparisons by hand.

Thank you for any help with my command!

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #1 on: January 15, 2019, 05:09:09 PM »
I was able to get one attribute to work, however if I try to do more than one attribute it doesn't work. I am hoping it is something simple.

This works
exiftool -d ~/Pictures/%Y/%m/%d/%Y%m%d_%H%M%S%%-c.%%e '-FileName<${Exif:DateTimeOriginal}_$ImageSize' ~/Photos
or
exiftool -d ~/Pictures/%Y/%m/%d/%Y%m%d_%H%M%S%%-c.%%e '-FileName<${Exif:DateTimeOriginal}_$Make' ~/Photos

However if I try to combine them it fails
exiftool -d ~/Pictures/%Y/%m/%d/%Y%m%d_%H%M%S%%-c.%%e '-FileName<${Exif:DateTimeOriginal}_$Make_$ImageSize' ~/Photos
« Last Edit: January 15, 2019, 05:26:28 PM by wk002 »

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #2 on: January 15, 2019, 05:24:26 PM »
Looks like this might be my pattern. In case anyone is following.

exiftool -r -d ~/Pictures/%Y/%m/%d/%Y%m%d_%H%M%S_ '-FileName<${Exif:DateTimeOriginal;}${Model;}_${Imagesize;}_${ShutterSpeed;}_${Aperture;}_${ISO;}%-c.%e' ~/Photos

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #3 on: January 15, 2019, 05:32:04 PM »
well the -testname command seemed to work but when I use -FileName it didn't

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2371
Re: Renaming files
« Reply #4 on: January 15, 2019, 08:08:09 PM »
I believe that the command will fail if the file is missing one of the tags that you are using to rename. 

As for the duplicates, there are programs out there that will look for duplicates based upon the images rather than differences in the file.  Visipics is common mentioned for Windows but there's also Dupeguru which has versions for Windows, Mac, and Linux.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #5 on: January 15, 2019, 08:11:47 PM »
I have tried several dup applications. Paid money for them and everything lol. I am left with this. If you can help me clean up the command. Right now it is naming my files like the below output but not moving it to the correct directory.

UsersjoshuaPictures2012011120120111_223407_Canon EOS 30D_2121x1414_1200_1.8_100

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2371
Re: Renaming files
« Reply #6 on: January 15, 2019, 08:40:40 PM »
A single long name, not in any subdirectory?

Ah, I got it.  Remove the trailing semicolon from Exif:DateTimeOriginal.  Adding the trailing semicolon activates the Advanced formatting feature default, which will remove slashes.  Normally it's used to remove unsafe characters from the filename, but since you have an explicit format due to the -d (dateFormat) option, it won't be needed and, as you can see, is actually a hindrance in this case.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #7 on: January 16, 2019, 12:30:19 PM »
I am making good progress. However I have some old Canon Raw files (.crw) that say there is no date time original exif data. However I show it when I use ExifTool to just read the data on one of the files (last line below). Is it possible the field is called something different then DateTimeOriginal on those old files?

Zorg:~ joshua$ exiftool /Users/joshua/Photos/2005/2005_06_23-4879.crw
ExifTool Version Number         : 11.25
File Name                       : 2005_06_23-4879.crw
Directory                       : /Users/joshua/Photos/2005
File Size                       : 7.1 MB
File Modification Date/Time     : 2005:06:23 22:03:44-04:00
File Access Date/Time           : 2019:01:16 12:27:21-05:00
File Inode Change Date/Time     : 2019:01:16 12:17:30-05:00
File Permissions                : rwxr-xr-x
File Type                       : CRW
File Type Extension             : crw
MIME Type                       : image/x-canon-crw
Raw Data                        : (Binary data 6181900 bytes, use -b option to extract)
Jpg From Raw                    : (Binary data 1232372 bytes, use -b option to extract)
File Format                     : CRW
Target Compression Ratio        : 10
Image Width                     : 3072
Image Height                    : 2048
Pixel Aspect Ratio              : 1
Rotation                        : 0
Component Bit Depth             : 8
Color Bit Depth                 : 24
Color BW                        : 257
Target Image Type               : Real-world Subject
Record ID                       : 0
File Number                     : 133-3370
Date/Time Original              : 2005:06:23 20:03:36

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14436
    • ExifTool Home Page
Re: Renaming files
« Reply #8 on: January 16, 2019, 12:56:09 PM »
Just drop the "Exif" and use just "DateTimeOriginal" instead of "Exif:DateTimeOriginal" in your command.

In CRW files, DateTimeOriginal is stored in the CanonRaw metadata, not EXIF.

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

wk002

  • Newbie
  • *
  • Posts: 7
Re: Renaming files
« Reply #9 on: January 16, 2019, 04:46:05 PM »
Thank you Phil. Great tool! Thank you very much for all your hard work.