Author Topic: Rename and move with one command.  (Read 531 times)

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Rename and move with one command.
« on: July 09, 2019, 12:47:54 PM »
Hello.
I can not figure out how to rename and move RAW files with different extensions from one folder to folders by year and day.

I have:

testfolder/
      file1.cr2
      file2.arw

I need:

2018/
      2018_12_23/
            20181223_165415.cr2
2019/
      2019_02_03/
            20190203_122532.arw

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3964
Re: Rename and move with one command.
« Reply #1 on: July 09, 2019, 01:13:25 PM »
Try this test command, alter the path as needed
exiftool -d "%Y_%m_%d/%Y%m%d_%H%M%S.%%e" "-Testname</path/to/targetfolder/$DateTimeOriginal"  testfolder/

If the results from that look right, then change Testname to Filename.  You don't mention your OS, so if you're on Mac/Linux, swap double quotes for single quotes.

Also, if there is a possibility of two pictures with the same time stamp, you might add -%%c to the date format after the %S so as to add an incremental number.
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #2 on: July 09, 2019, 02:11:36 PM »
Спасибо, буду пробовать.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #3 on: July 10, 2019, 07:35:58 AM »
For me this option:

exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S.%%e" "-FileName<D:\_\test\$DateTimeOriginal" .

But how to adding File Number to end to file name?
I have "File number : 101-245" tag in my .cr2.
I need:

20180225_1546_101-245.cr2

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1140
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Rename and move with one command.
« Reply #4 on: July 10, 2019, 10:54:42 AM »
Advanced formatting should allow for this, try:
Code: [Select]
exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S.%%e" "-FileName<${DateTimeOriginal;$_=qq(D:\\_\\test\\$_$$self{FileNumber})}" .
Hayo Baan – Photography
Web: www.hayobaan.nl

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3964
Re: Rename and move with one command.
« Reply #5 on: July 10, 2019, 11:23:57 AM »
Or just move the extension out of the date string

exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S" "-FileName<D:\_\test\${DateTimeOriginal}_$FileNumber.%e" .
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #6 on: July 10, 2019, 12:16:11 PM »
Advanced formatting should allow for this, try:
Code: [Select]
exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S.%%e" "-FileName<${DateTimeOriginal;$_=qq(D:\\_\\test\\$_$$self{FileNumber})}" .
I'm trying it, but it doesn't work.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #7 on: July 10, 2019, 12:18:51 PM »
Or just move the extension out of the date string

exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S" "-FileName<D:\_\test\${DateTimeOriginal}_$FileNumber.%e" .

It works.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3964
Re: Rename and move with one command.
« Reply #8 on: July 10, 2019, 01:10:35 PM »
I'm trying it, but it doesn't work.

Strange.  I copy/pasted the command and it worked here.  Glad the other version works for you, but I'm still curious about the error.  What version of exiftool are you using?
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #9 on: July 10, 2019, 02:12:54 PM »
Спасибо за помощь.

I'm attached screenshot. Hope this helps.
« Last Edit: July 10, 2019, 02:28:08 PM by andreikorzhyts »

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3964
Re: Rename and move with one command.
« Reply #10 on: July 10, 2019, 02:35:34 PM »
Strange.  The command appears to be correct.  But I can't replicate the error here.

Anyway, glad we got a working version for you.
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.

Andrei Korzhyts

  • Sr. Member
  • ****
  • Posts: 236
Re: Rename and move with one command.
« Reply #11 on: July 10, 2019, 04:34:31 PM »
Спасибо, буду использовать этот вариант.