ExifTool Forum

ExifTool => Newbies => Topic started by: haneulso on September 25, 2018, 08:10:53 AM

Title: Rename and sort
Post by: haneulso on September 25, 2018, 08:10:53 AM
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.
Title: Re: Rename and sort
Post by: Phil Harvey on September 25, 2018, 08:59:33 AM
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

Title: Re: Rename and sort
Post by: haneulso on September 25, 2018, 06:59:43 PM
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. 
Title: Re: Rename and sort
Post by: StarGeek on September 25, 2018, 09:24:22 PM
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.
Title: Re: Rename and sort
Post by: Phil Harvey on September 25, 2018, 09:48:50 PM
Right.  Thanks StarGeek.  I forgot to start from the unformatted creation date (CreateDate#). 

- Phil
Title: Re: Rename and sort
Post by: haneulso on September 26, 2018, 03:52:11 AM
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

Title: Re: Rename and sort
Post by: Phil Harvey on September 26, 2018, 08:58:50 AM
Can you post the command you used?  Did you also swap the single quotes back to double quotes?

- Phil
Title: Re: Rename and sort
Post by: haneulso on September 26, 2018, 05:54:52 PM
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.
Title: Re: Rename and sort
Post by: StarGeek on September 26, 2018, 06:24:07 PM
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' .
Title: Re: Rename and sort
Post by: haneulso on September 26, 2018, 06:35:16 PM
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.