preserve original filename

Started by goat, December 28, 2014, 07:55:39 AM

Previous topic - Next topic

goat

Can someone point me in the right direction about how to preserve the original filename of an image when using exiftool to rename a file based in the date and time in the exif data
essentially something like this

2014-12-27 at 19-17-22_"originalfilename".jpg

cheers

Phil Harvey

You want the new file name to contain the old name?  The command would look something like this:

exiftool "-filename<${datetimeoriginal}_$filename" -d "%Y-%m-%d at %H-%M-%S" DIR

where DIR is the name of a directory containing the images.  (The above quoting is for Windows.  Use single quotes instead if you are on Max/Linux)

Be sure to test this command first to make sure it does what you want because it is difficult to go back after renaming a file.

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

goat

Thankyou!

_$filename was the snippet I was missing

Cheers



Christian72D

Can you help me?
I want to create a directory depending on the date, but want to preserve the filename.

I found THIS code for creating the directory, that works fine.
/usr/bin/exiftool "-filename<CreateDate" -d "/volume1/photo/%Y-%m/%Y-%m-%d %H-%M-%S%%-c.%%le" -r /volume1/import

But when i change it to /usr/bin/exiftool "-filename<CreateDate" -d "/volume1/photo/%Y-%m-%d/%filename" -r /volume1/import it won´t work.

And it looks like that " is working better with linux than '. Was it changed?

Luuk2005

Greetings Christian. Please try %%f for producing original filenames, so maybe it can be something like ...
exiftool -TESTname'<CreateDate' -d '/volume1/photo/%Y-%m/%Y-%m-%d %H-%M-%S/%%f%%-c.%%le' -r /volume1/import
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

StarGeek

Since you're just moving the file rather than renaming it, use Directory instead of Filename (see Writing "FileName" and "Directory" tags, also see the -d (dateFormat) option for details on times you have to double the percent sign).
exiftool '-Directory<CreateDate' -d '/volume1/photo/%Y-%m-%d' -r /volume1/import

I also changed the double quotes to single quotes.  Either can be used for this command, but there are commands when run on linux/Mac that would require single quotes and it's a good habit to get into.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Luuk2005

Greetings StarGeek. Many thanks for the extra information, its good advice.
Im wish to mention writing $Directory, but cant invent ways to include %c for duplicate names? Is this to be possible????
The problem is I never write $Directory, because $TESTname makes easier experiments (I wish for $TESTDirectory to experiment without -p command).
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

StarGeek

Quote from: Luuk2005 on December 29, 2020, 10:04:16 PM
Im wish to mention writing $Directory, but cant invent ways to include %c for duplicate names? Is this to be possible????

The %c won't really work when moving a file using the Directory pseudo tag.  But @Christian72D only wanted to move and wasn't using %c, which is why I suggested using Directory instead.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype