News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Rename and sort

Started by haneulso, September 25, 2018, 08:10:53 AM

Previous topic - Next topic

haneulso

I want to do some works.

First, rename digital camera files(jpg ext) along with createdate and camera model and maker(ex, 20170809-123215DMC-Fx10Panasonic.jpg).

Second, make directory with CameraModel(ex, DMC-Fx10).

Third, create year\months sub directory under CameraModel directory(ex, DMC-Fx10)

Fourth, move renamed files to year\months directory.

Thanks.

Phil Harvey

This command should do what you want:

exiftool "-filename<${model;}/${createdate;DateFmt('%Y/%m')}/$createdate${model;}${make;}%-c.%e" -ext jpg -d "%Y%m%d-%H%M%S" DIR

You should run this from the directory where you want the other directories to be created.  I have added a %-c to avoid name conflicts in the case that two pictures have the same date/time.

First run the command using "testname" instead of "filename" to be  sure it is doing what you want before actually renaming/moving the files.

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

haneulso

Thanks.

Your script work well.

It makes  directory included model and file rename included model and make.

But two minor problem is.

First, every file has its own directory.

So, if one original directory has 1170 jpg files, there are 1170 sub directories which have its own directory name and every sub directories has only one file.


Camera Model(DMC-FX10) - createdate(20090312-004421) - createdateModelMake(20090321-004421DMC-FX10Panasonic.JPG)

   DMC-FX10 - 20090321-004414 - 20090321-004414DMC-FX10Panasonic.JPG

   DMC-FX10 - 20090321-004421 - 20090321-004421DMC-FX10Panasonic.JPG

   DMC-FX10 - 20090321-004438 - 20090321-004438DMC-FX10Panasonic.JPG

   .
   .

I want to gather files which were took same month in one directory(ex, 200903) .


Second, script shows error message.

Warning: Global symbol "%Y" requires explicit package name (did you forget to declare "my %Y"?) at (eval 110442) line 1.
Global symbol "%m" requires explicit package name (did you forget to declare "my %m"?) for 'createdate' - ./20093To2011506/20090715/P1050789.JPG
.
.
.

Is it minor?

Thanks. 

StarGeek

I think you need to add a hashmark to use the DateFmt option.
"-filename<${model;}/${createdate#;DateFmt('%Y/%m')}/$createdate${model;}${make;}%-c.%e"

Otherwise the command should work properly.  Are you using -Filename, not -Directory?  What OS are you using?  If you are on Mac/Linux, swap double/single quotes.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Right.  Thanks StarGeek.  I forgot to start from the unformatted creation date (CreateDate#). 

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

haneulso

Thanks  StarGeek and Phill.

The result with "createdate#" is same.

One image file has its own directory. But, this time sub directory's name is some different.

   DMC-FX10 - 2009:03:21 00:44:14 - 20090321-004414DMC-FX10Panasonic.JPG

And same warning message appears.

My system is linux, so I swap double to single quotes.

If I replace "-filename" with "-Directory", another subdirectory appears and no rename happens(remain original jpg file name).

DMC-FX10 - 2009:03:21 00:44:14 - 20090321-004414DMC-FX10Panasonic.JPG - P1050003.JPG


Phil Harvey

Can you post the command you used?  Did you also swap the single quotes back to double quotes?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

haneulso

If I use,

exiftool  '-filename<${model;}/${createdate#;DateFmt('%Y/%m')}/$createdate${model;}${make;}%-c.%e' -ext jpg -d '%Y%m%d-%H%M%S' .

The result

DMC-FX10/2009:07:15 03:37:51/20090715-033751DMC-FX10Panasonic-1.JPG


If I use it without #

exiftool  '-filename<${model;}/${createdate;DateFmt(%Y/%m)}/$createdate${model;}${make;}%-c.%e' -ext jpg -d '%Y%m%d-%H%M%S' .

The result

DMC-FX10/20090711-091708/20090711-091708DMC-FX10Panasonic.JPG


My system is ubuntu 18.0.4.

Thanks.

StarGeek

Swap the single quotes after DateFmt to double quotes.

exiftool  '-filename<${model;}/${createdate#;DateFmt("%Y/%m")}/$createdate${model;}${make;}%-c.%e' -ext jpg -d '%Y%m%d-%H%M%S' .
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

haneulso

Fantastic!!!

It works well.

The result is

DMC-FX10/2009/03/20090321-004414DMC-FX10Panasonic.JPG

And each month sub directory (ex, 2009/03) has all files which were took same month(ex, 2009/03).

Thanks.