Author Topic: Renaming files  (Read 940 times)

wk002

  • Newbie
  • *
  • Posts: 9
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: 9
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: 9
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: 9
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: 3691
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: 9
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: 3691
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: 9
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: 16534
    • 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: 9
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.

wk002

  • Newbie
  • *
  • Posts: 9
Re: Renaming files
« Reply #10 on: June 08, 2020, 01:29:03 AM »
I have been fighting my duplicate problem for years now lol.

I do appreciate all the wonderful documentation and community support. I am hoping someone might be able to help me put the last nail in the coffin here.

If I can reset all files back to default. At least as much as possible. I might be able to find the files that are missing data (manually one month at a time)

I would like to reset the orientation of all my files to Normal or 1 depending on how you like to read it, and I would like to reset all dates back to the DateTimeOriginal
aka
File Modification Date/Time
File Access Date/Time
File Inode Change Date/Time
Modify Date
Create Date
any others?

I am hoping if I can do that then rename all files in all subdirectories to "%Y/%m/%d/%Y%m%d_%H%M%S_{Model;}_${ShutterSpeed;}_${Aperture;}_${ISO;}_${Imagesize;}%-c.%%e" (I could use some help with this command too please)

Then I can go through the tedious task of looking at anything with a "-x" in the name and help me find dups or find anything that has a bad value on image size since I have found some images are thumbnails from iPhoto or Aperture not sure which one.

I do appreciate any help. I don't know if I should continue my original thread or open a new one. If someone tells me I need to open a new one then I am happy to do so.

Again thank you for any help :)

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3691
Re: Renaming files
« Reply #11 on: June 08, 2020, 01:17:00 PM »
I would like to reset the orientation of all my files to Normal or 1 depending on how you like to read it

Do you want to set the Orientation to Horizontal (1) regardless of how it needs to be actually viewed?  Or do you mean you want the image losslessly rotated to the to match an Orientation of Horizontal?  For the first, you could use -Orientation=Horizontal or even remove the Orientation with -Orientation= and any program you view it with will display it without rotating.

Quote
and I would like to reset all dates back to the DateTimeOriginal
aka
File Modification Date/Time
File Access Date/Time
File Inode Change Date/Time
Modify Date
Create Date
any others?

There are other tags, but they would be rarely used by most programs.  FileInodeChangeDate is not writable by exiftool, but for the others you could use
'-AllDates<DateTimeOriginal '-FileModifyDate<DateTimeOriginal' '-FileCreateDate<DateTimeOriginal'

Quote
I am hoping if I can do that then rename all files in all subdirectories to "%Y/%m/%d/%Y%m%d_%H%M%S_{Model;}_${ShutterSpeed;}_${Aperture;}_${ISO;}_${Imagesize;}%-c.%%e"

Try this to see if it works for you, then replace Testname with Filename if it works correctly
exiftool -d '%Y/%m/%d/%Y%m%d_%H%M%S' '-TestName<${DateTimeOriginal}_{Model;}_${ShutterSpeed;}_${Aperture;}_${ISO;}_${Imagesize;}%-c.%e' /path/to/files
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: 9
Re: Renaming files
« Reply #12 on: June 23, 2020, 05:41:51 PM »
Quote
Do you want to set the Orientation to Horizontal (1) regardless of how it needs to be actually viewed?  Or do you mean you want the image losslessly rotated to the to match an Orientation of Horizontal?  For the first, you could use -Orientation=Horizontal or even remove the Orientation with -Orientation= and any program you view it with will display it without rotating.

Honestly I am not sure how to answer this one. I am using a duplicate finder application to weed out the dups. I have some that are rotated and some that are not. I would prefer that they be what they should be. So if it should be rotated when I look at the thumbnail and open the file in Lightroom etc I would like to see it how it was taken. However at this point I am just trying to reset things so the duplicate application is comparing apples to apples.

As for the dates... Again I am just trying to reset all the meta data and the image to what ever defaults I can so when the duplicate finder scans them it sees duplicate data.

Also if I want the extension to be lowercase do I use .le?

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3691
Re: Renaming files
« Reply #13 on: June 25, 2020, 06:20:33 PM »
I am using a duplicate finder application to weed out the dups.

Just a duplicate file app?  Or one that works on the image content, such as VisiPics?

A simple duplicate finder app will not match files even if the metadata is the same, but they were edited by different programs.  For example, the same metadata edited by ExifTool will have some structural differences than one edited by Lightroom.

Some Digital Asset Manager (DAM) programs have the ability to search for duplicates based upon the actual image.  For example IMatch (commercial) or Digikam (free) can do so.

Quote
As for the dates... Again I am just trying to reset all the meta data and the image to what ever defaults I can so when the duplicate finder scans them it sees duplicate data.

There really isn't a default for dates

Quote
Also if I want the extension to be lowercase do I use .le?

%le, or %%le if used in a date format string.
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.