ExifTool Forum

ExifTool => Newbies => Topic started by: j99mac on October 27, 2021, 09:13:20 AM

Title: Renameing files with date and time
Post by: j99mac on October 27, 2021, 09:13:20 AM
I am looking to rename files based on CreateDate and CreateTime. Is it posable to add a custom Date and Time to filename? The Date format I am looking for is yymmdd and the time format is hmma. I the without any: in the date or time.
Would this command work?
exiftool -d '%Y%m%d''%h%mm$a' '-FileName<${CreateDate;}_$Num_${CreateTime;}_Start%.2nc.%e' "$files"
Title: Re: Renameing files with date and time
Post by: StarGeek on October 27, 2021, 10:17:07 AM
I don't believe there's a tag called "CreateTime".  At least I can't create one with exiftool.  Where are you getting the value for this?

If you want to have two different date formats, then you need to use the DateFmt helper function (https://exiftool.org//exiftool_pod.html#Helper-functions).  Something like
exiftool '-FileName<${CreateDate;DateFmt("%Y%m%d")}_$Num_${CreateTime;DateFmt("%H%M")}_Start%.2nc.%e' /path/to/files/
Title: Re: Renameing files with date and time
Post by: j99mac on October 27, 2021, 10:36:18 AM
Would this put the date and the time form DateTimeOriginal feild?
Title: Re: Renameing files with date and time
Post by: StarGeek on October 27, 2021, 10:40:57 AM
I was just using your original post as an example.  I still don't know where you got this "CreateTime" tag from.
Title: Re: Renameing files with date and time
Post by: j99mac on October 27, 2021, 10:49:19 AM
I Thought that there was a Create time.
Could this be used DateTimeOriginal
Title: Re: Renameing files with date and time
Post by: Phil Harvey on October 27, 2021, 11:22:45 AM
You can use any tags that you find with this command:

exiftool -s -time:all FILE

- Phil
Title: Re: Renameing files with date and time
Post by: j99mac on October 27, 2021, 11:44:07 AM
is this better
exiftool -p "${DateCreated}_$Num_${TimeCreated}_Start.tif" -d %Y%m%d_%H%M%S%%-c /path/to/files/

This is what I want the file name
211027_%Num_100010_Start.tif
Title: Re: Renameing files with date and time
Post by: Phil Harvey on October 27, 2021, 12:41:53 PM
OK.  So you can use most tags that you find with the command I gave.  But it must be a date/time tag.  Use DateTimeCreated instead of DateCreated and TimeCreated.  Does the DateTimeCreated tag exist in all your files?

Also, I don't know what you are trying to do with $Num in the name.

- Phil
Title: Re: Renameing files with date and time
Post by: j99mac on October 27, 2021, 01:56:15 PM
Yes there is a date/time tag in my files. If I cange DateCreated to DateTimeCreated and TimeCreated to DateTimeCreated  can I make one have date  and the other have just time

$Num I a read Veriable where a user cam example

Echo "Enter a Number"
read Num
Title: Re: Renameing files with date and time
Post by: Phil Harvey on October 27, 2021, 02:11:24 PM
I can't help with your $Num (are you on Windows? are you executing this from a batch file?  If so, then it is likely %Num%, and all other % characters need to be doubled.)

Quote from: j99mac on October 27, 2021, 01:56:15 PM
If I cange DateCreated to DateTimeCreated and TimeCreated to DateTimeCreated  can I make one have date  and the other have just time

StarGeek showed you how to do this.

- Phil
Title: Re: Renameing files with date and time
Post by: j99mac on October 28, 2021, 11:03:46 AM
This is what he has
exiftool -r '-FileName<CreateDate' -d '%Y-%m-%d/%H_%M_%S%%-c.%%le' <yourFolder>

I am looking for the name to be date_veriable_Time_Start
Title: Re: Renameing files with date and time
Post by: StarGeek on October 28, 2021, 11:12:39 AM
Quote from: StarGeek on October 27, 2021, 10:17:07 AM
exiftool '-FileName<${CreateDate;DateFmt("%Y%m%d")}_$Num_${CreateTime;DateFmt("%H%M")}_Start%.2nc.%e' /path/to/files/

You'll have to figure out what the exact tag you want to use is and you'll have to figure out the proper context for your variable, but otherwise your command is along these lines.
Title: Re: Renameing files with date and time
Post by: j99mac on October 28, 2021, 11:56:37 AM
I get" no writable tag sets" when running the comand
Title: Re: Renameing files with date and time
Post by: Phil Harvey on October 28, 2021, 12:44:04 PM
We are going around in circles here.  Please read our previous posts