Author Topic: Trying to rename file creates an empty file  (Read 2807 times)


  • Jr. Member
  • **
  • Posts: 22
Trying to rename file creates an empty file
« on: November 28, 2010, 10:36:49 AM »

I've used ExifTool for a few years now. Thanks for a great program! Much better than the hack I was trying to write before I discovered ExifTool.

While attempting to rename .MOV files according to the date the video was taken, I noticed the date inside the file was (most likely) in the Zulu/GMT timezone. Since ExifTool cannot write to MOV files, I tried to change the time on the fly with the following command:
exiftool -P "-FileName<${CreateDate}-04:00" -d "%Y-%m-%d_%H-%M-%S%%+c.%%e" -directory=Done "file.MOV"

I naively expected that the CreateDate would be brought back by 4 hours and the resulting filename would be in my local timezone. Instead, I obtained the following file: 2010-08-01_18-47-32.MOV-04, but the file was empty!

If I use the following command:
exiftool -P "-FileName<${CreateDate}-04" -d "%Y-%m-%d_%H-%M-%S%%+c.%%e" -directory=Done "file.MOV"
the resulting file is 2010-08-01_18-47-32.MOV-04, and the contents are intact. So it looks like the ":00" at the end of the file name specification confuses ExifTool.

I realize that my attempt to change the date/time by applying a math operator on the value of the CreateTime tag was naive at best (I had to try!), but I thought I'd report this potentially destructive behavior.

The usual information:
Code: [Select]
Windows XP Pro SP3
> exiftool -ver
> uname -a
CYGWIN_NT-5.1 borduas 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin


PS. To solve my timezone problem, I'll try creating a user-defined tag in my config file, to have Perl do the math. But that's not the topic of the current post.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17044
    • ExifTool Home Page
Re: Trying to rename file creates an empty file
« Reply #1 on: November 28, 2010, 05:04:45 PM »
Hi Martin,

ExifTool will certainly not get confused by this filename, but a colon in a Windows filename is a special character and I don't know how Windows would respond to this.  I don't filter out colons because they are valid in filenames on other types of systems.

There are two ways to do the time shift: 1) create a user-defined tag which is a shifted version of your date/time tag (there is an example of this you should be able to find in the archives on this forum, try searching for "UserDefined" and "shift" and "time").  2) Copy the date/time temporarily to the FileModifyDate, then shift this time, then use it to set the filename.  This method isn't quite as clean though.

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


  • Jr. Member
  • **
  • Posts: 22
Re: Trying to rename file creates an empty file
« Reply #2 on: November 29, 2010, 10:54:53 PM »
Thanks for the explanation.

I also found the previous post on custom time-shifting. Thanks for that too.