Author Topic: File Renaming in windows, help with empty fields  (Read 3606 times)

ChaosEmpire

  • Newbie
  • *
  • Posts: 4
File Renaming in windows, help with empty fields
« on: September 04, 2014, 10:49:09 AM »
Hi

after a while i was able to get my files named in a way, i liked it to have since years
my old renamer has ahd some issues, which drove me crazy

and since i used exiftool for other things already, i started a file rename in windows

but now my problems start...

- I dont want rename files, if there is no date inside
- i want to set only a name part once...independent if its in 2 or more tags

here is my example

my old D70s used Usercomment, the newer D7100/D810 use Copyright/Artist
if this is empty _${artist;}_${copyright;} use this ${UserComment;}
my issue is, for every empty field i get the _, as i cant find a way to set leave fields plus "textdescriptions like f or _" away

_s${ExposureTime;}_s${shutterspeed;}
in this example, both fields get used in my cams, but in some pics of friends there is only one used...
i m looking for a way to set the prefered if available, and if empty use the other field...and if not existit..like above..dont print anything for this

hope its not to confusing

btw this would also help to get files renamed, if some of the date fields are empty, so xyou can make a prefered order list like DateCreated,DateModified and so on...so if one is empty, look and use next, if empty use last variant...

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17190
    • ExifTool Home Page
Re: File Renaming in windows, help with empty fields
« Reply #1 on: September 04, 2014, 11:40:50 AM »
Well, I am confused.  But it sounds like the -if condition will be your friend.

You may want to run a number of commands, processing images that satisfy certain conditions, such as:

exiftool -if "defined $exposuretime and defined $createdate" -d %Y%m%d "-filename<${createdate}_${exposuretime;tr(/)(-)}" ...

(the quoting above is for Windows, Mac/Linux users will need single quotes)

Note that I have translated "/" to "-" in the exposure time, otherwise with a time like "1/60" the "/" would be taken as a directory separator.

- 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 ($).

ChaosEmpire

  • Newbie
  • *
  • Posts: 4
Re: File Renaming in windows, help with empty fields
« Reply #2 on: September 04, 2014, 11:54:54 AM »
Hahaha, I expected to get you confused...my english is not the best

Here is an example of my tries and errors...

exiftool -a -m -r -d %%Y-%%m-%%d_%%Hh%%Mm%%Ss%%%%-c "-filename<${CreateDate}_${UserComment;}_${artist;}_${copyright;}_${ColorSpace;}_s${ExposureTime;}_s${shutterspeed;}_f${aperture;}_i${Iso;}_${FocalLength;}_${Model;}.%%e" %1

this leads to

2012-07-22_17h36m33s_(c) MyName_MyCompany___sRGB_s1100_s1100_f5.6_i200_200.0 mm_NIKON D70s

the ___ is from empty copyright/artist fields (best those wont appear, if the other is empty, or vice versa..as usercomment is outfdated in my using)
the doubled s1100 is from exposure time and shutterspeed (this is by both fille din Nikon, but i want only one)

and IF createdate is empty check for and use date original, but if this is empty use the modified date..anmd if even this is empty, dont do anything to the files at all (so leave maybe personal naimngs untouched of files without exif...this happened when i used parameter imagesize.... ___________________800_600.jpg ...the name before was better :) )

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17190
    • ExifTool Home Page
Re: File Renaming in windows, help with empty fields
« Reply #3 on: September 04, 2014, 12:07:05 PM »
OK, so how about this?:

1. exiftool -if "$createdate" -a -m -r -d %%Y-%%m-%%d_%%Hh%%Mm%%Ss%%%%-c "-filename<${CreateDate}_${UserComment;}_${artist;}_${copyright;}_${ColorSpace;}_s${ExposureTime;}_s${shutterspeed;}_f${aperture;}_i${Iso;}_${FocalLength;}_${Model;}.%%e" %1

2. exiftool -if "$modifydate and not $createdate" -a -m -r -d %%Y-%%m-%%d_%%Hh%%Mm%%Ss%%%%-c "-filename<${ModifyDate}_${UserComment;}_${artist;}_${copyright;}_${ColorSpace;}_s${ExposureTime;}_s${shutterspeed;}_f${aperture;}_i${Iso;}_${FocalLength;}_${Model;}.%%e" %1
...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 ($).

ChaosEmpire

  • Newbie
  • *
  • Posts: 4
Re: File Renaming in windows, help with empty fields
« Reply #4 on: September 04, 2014, 12:11:28 PM »
so i need many lines with if statements, when i get you right

three for the variant of the date field possibilities, and then double this again for the check if shutterspeed is empty but exposure time filled

brackets and else could be helpfull...(i use it at the moment in the sendto shell hope i dont brake the limit, but several command lines wont be possible their at all, so back to batches and doubled % :) )

BTW thanks for lighning speed fast answers

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17190
    • ExifTool Home Page
Re: File Renaming in windows, help with empty fields
« Reply #5 on: September 04, 2014, 12:25:41 PM »
OK.  If there are too many possibilities, then the solution is to handle the logic by creating a user-defined Composite tag to generate the file name for you.  Search for "UserDefined Composite" in the forum for examples.

- 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 ($).

ChaosEmpire

  • Newbie
  • *
  • Posts: 4
Re: File Renaming in windows, help with empty fields
« Reply #6 on: September 04, 2014, 02:40:18 PM »
ok, thanks phil, i will search :)