Rename and Move file in one command line?

Started by Dal, July 01, 2010, 05:26:31 PM

Previous topic - Next topic

Dal

Hi, and thank you for a wonderful tool.

Here's my problem:

I want to rename my AVCHD files to the date/time they are taken, and I also want to move the files to a directory named after the day they are taken. But I want the directory name to be formatted another way than the file name.

Seperatly, these two things work fine, but is it possible to do in one command line?

I have this command line (I operate in Windows):
exiftool -d "%Y-%m-%d_kl.%H%M%%-c -(%%f).%%e" "-filename<H264:DateTimeOriginal" -execute -d "%Y-%m-%d" "-directory<H264:DateTimeOriginal" filename.M2TS

And of course this line does not work, because the first part renames the file, and then the second part cannot find any file to extract info from :)

Any idea how to achieve this?
The name the file(s) are renamed to should be "caught" somehow to be used in the other part of the command line?

Someone else must have encountered this problem too :)

Thank you.

Phil Harvey

You can do this with a command like this:

exiftool -d "%Y-%m-%d/%Y-%m-%d_kl.%H%M%%-c -(%%f).%%e" "-filename<H264:DateTimeOriginal" filename.M2TS

Writing the FileName tag also moves the file if a directory is specified.

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

Dal

Quote from: Phil Harvey on July 02, 2010, 07:04:32 AMYou can do this with a command like this:
exiftool -d "%Y-%m-%d/%Y-%m-%d_kl.%H%M%%-c -(%%f).%%e" "-filename<H264:DateTimeOriginal" filename.M2TS

Hello, and thanks for answering.
I'm sorry for the late reply, I've been away on vacation :)

Anyway, that command line did the trick! I stared and stared at the line trying to figure out what made it special until I noticed the "\" in there :)

Quote from: Phil Harvey on July 02, 2010, 07:04:32 AMWriting the FileName tag also moves the file if a directory is specified.

I did not understand this, though. Do you have the time to explain?

Then the next job is to set up a script for Directory Opus so I can choose multiple files (or even whole directories) and renaming and moving my movie files the easy way! :)

Thanks again.

Dal

Quote from: Dal on July 14, 2010, 05:35:06 PM
Then the next job is to set up a script for Directory Opus so I can choose multiple files (or even whole directories) and renaming and moving my movie files the easy way! :)

Regarding this; when trying this script on a directory, it does not work. It gives this output: 1 directories scanned - 0 image files read

This is the script: exiftool -d "%Y-%m-%d/%Y-%m-%d_kl.%H%M%%-c -(%%f).%%e" "-filename<H264:DateTimeOriginal" DirectoryName

BTW: This is from command prompt, not from Directory Opus.

Any tips?
I hope it is possible to do both files and directories in one command line, that would be sweet.

Thanks again.

Phil Harvey

Sorry, I should have added -ext m2ts to the command to process M2TS files.

Quote from: Dal on July 14, 2010, 05:35:06 PM
Quote from: Phil Harvey on July 02, 2010, 07:04:32 AMWriting the FileName tag also moves the file if a directory is specified.

I did not understand this, though. Do you have the time to explain?

Just as you noticed, a directory is specified before the "/" in the file name.

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

Dal

Quote from: Phil Harvey on July 15, 2010, 07:25:39 AM
Sorry, I should have added -ext m2ts to the command to process M2TS files.
Fantastic, that seemed to work splendidly.
Can you add more extensions to the same line, say *.m2ts and *.mts?

Thanks.

Dal

Never mind that last question, I actually looked up in the documentation :)
But one thing I didn't find out: Can it be set up to check/process ALL filetypes in a directory?

Also, can exiftool be set to scan several directories down, into sub-directories, if you know what I mean?

Thanks again.

Phil Harvey

Quote from: Dal on July 15, 2010, 01:44:00 PM
But one thing I didn't find out: Can it be set up to check/process ALL filetypes in a directory?

No.  You can only do this with '*' on the command line, but this won't work to process all files in subdirectories (see answer to next question).

Quote
Also, can exiftool be set to scan several directories down, into sub-directories, if you know what I mean?

Yes.  The -r option will recurse into any subdirectories specified on the command line.  This is when the -ext option really comes in handy to specify the files to process in the subdirectories (you can have multiple -ext options as you probably have already figured out).

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

Dal

Ok, I thank you for all your help (so far) :)