ExifTool Forum

ExifTool => Newbies => Topic started by: Jom on July 09, 2019, 12:47:54 PM

Title: Rename and move with one command.
Post by: Jom 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
Title: Re: Rename and move with one command.
Post by: StarGeek 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.
Title: Re: Rename and move with one command.
Post by: Jom on July 09, 2019, 02:11:36 PM
Спасибо, буду пробовать.
Title: Re: Rename and move with one command.
Post by: Jom 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
Title: Re: Rename and move with one command.
Post by: Hayo Baan on July 10, 2019, 10:54:42 AM
Advanced formatting should allow for this, try:
exiftool -r -d "%Y/%Y%m%d/%Y%m%d_%H%M%S.%%e" "-FileName<${DateTimeOriginal;$_=qq(D:\\_\\test\\$_$$self{FileNumber})}" .
Title: Re: Rename and move with one command.
Post by: StarGeek 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" .
Title: Re: Rename and move with one command.
Post by: Jom on July 10, 2019, 12:16:11 PM
Quote from: Hayo Baan on July 10, 2019, 10:54:42 AM
Advanced formatting should allow for this, try:
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.
Title: Re: Rename and move with one command.
Post by: Jom on July 10, 2019, 12:18:51 PM
Quote from: StarGeek 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" .

It works.
Title: Re: Rename and move with one command.
Post by: StarGeek on July 10, 2019, 01:10:35 PM
Quote from: andreikorzhyts on July 10, 2019, 12:16:11 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?
Title: Re: Rename and move with one command.
Post by: Jom on July 10, 2019, 02:12:54 PM
Спасибо за помощь.

I'm attached screenshot. Hope this helps.
Title: Re: Rename and move with one command.
Post by: StarGeek 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.
Title: Re: Rename and move with one command.
Post by: Jom on July 10, 2019, 04:34:31 PM
Спасибо, буду использовать этот вариант.