Main Menu

help verifying my cmd

Started by dogsofwar, July 06, 2024, 10:20:57 PM

Previous topic - Next topic

dogsofwar

I want to rename around 50 thousand files that include pics and vids. I want the file names to be based on date taken and named YearMD_HMS and keep the file extensions the same as they are now. Then I want to move all files to new folders that are Year_Month. If a file exists then add a copy number to the file name.

Please let me know if there is anything else that I should consider doing to organize this stuff? Below is what I have so far. I want to move files missing a create date to another folder, but I'm not sure if I can do that in this command or if I have to run a 2nd one?

exiftool -r "-TestName<CreateDate" -d e:\NewDirectory\%Y-%m-%d/%Y%m%d_%H%M%S%%-c.%%e e:\newdirectory

StarGeek

I don't see any problems with it.

To cover files that don't have a CreateDate, you would place that before this one. That's because when two different values are assigned to the same tag, the latter takes precedent. If that fails, the command falls back the previous assignment

Here, if the file doesn't have a CreateDate, then files will be moved to the e:\NewDirectory\MissingDate directory, with a copy number if needed. Once you change Testname to Filename, of course.
exiftool -r "-TestName=e:\NewDirectory\MissingDate\%f%-c.%e" "-Testname<CreateDate" -d e:\NewDirectory\%Y-%m-%d/%Y%m%d_%H%M%S%%-c.%%e e:\newdirectory

If you plan on using this in a BAT file, see FAQ #27, My ExifTool command doesn't work from a Windows .BAT file.
* 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).

dogsofwar

#2
Thank you! If I run this on many subfolders do I need to run it in a bat file?

I am learning this, so in the cmd which flag does the directory creation? I read some of the instruction pages and there was a reference to the "directory" flag, but that's not in the cmd below and it still works? Or is it the "new directory" that does it?

exiftool -r "-TestName=e:\NewDirectory\MissingDate\%f%-c.%e" "-Testname<CreateDate" -d e:\NewDirectory\%Y-%m-%d/%Y%m%d_%H%M%S%%-c.%%e e:\newdirectory


StarGeek

Quote from: dogsofwar on July 06, 2024, 10:48:11 PMThank you! If I run this on many subfolders do I need to run it in a bat file?

No, you can run it directly on the command line. I just mentioned the BAT file FAQ because it's a common next question, or people will say it doesn't work without mentioning they are using a BAT file.

QuoteI am learning this, so in the cmd which flag does the directory creation? I read some of the instruction pages and there was a reference to the "directory" flag, but that's not in the cmd below and it still works? Or is it the "new directory" that does it?

Copying to the Filename tag will also create directories if they are part of the command. Exiftool will create new directories as needed.

See Writing "FileName" and "Directory" tags for more details.
* 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).

dogsofwar

#4
I am getting a bunch of errors that the file already exists when I run this command. I am not sure where I'm going wrong.

I have all of my photos in folders under the e:\mess directory. I am trying to rename the photos with the createdate and organize them into folders under e:\organized.  If a file exists with the same name then I have the part to put a copy number in.

When I do a test run I get errors that the files exist. The errors below are just a few of the many I am getting. Is it correct to put the folder that I am running this against at the end of the command where I have it now? I created a root folder titled organized and then I want the folders created for Year\Year_Month\Year_Month_Day

I also wanted to ask why there has to be double %% after the S and then for the copy number?

The command is:
exiftool -r "-TestName=e:\organized\MissingDate\%f%-c.%e" "-Testname<CreateDate" -d e:\organized\%Y\%Y_%m\%Y_%m_%d/%Y%m%d_%H%M%S%%-c.%%e e:\mess

Some of the errors are:
Warning: File 'e:/mess/' already exists - e:/mess/0332_0332_20181130_033236.mov
Warning: File 'e:/mess/' already exists - e:/mess/1301_1301_20150904_130110.jpeg
Warning: File 'e:/mess/' already exists - e:/mess/1414_1414_20160806_141444.JPG
Warning: File 'e:/mess/' already exists - e:/mess/1546_1546_20200811_154656.JPG
Warning: File 'e:/mess/' already exists - e:/mess/1713_1713_20190825_171308.mp4
Warning: File 'e:/mess/' already exists - e:/mess/1802_1802_20210719_180257.mp4
Warning: File 'e:/mess/' already exists - e:/mess/1855_1855_20150602_185521.JPG

Phil Harvey

I can't see how you could get errors like this if you are running directly in a CMD window (ie. not in PowerShell or from a .bat file).

The double %%-c and %%e are to get %-c and %e through the date/time parser.  You have to re-double all %'s if you are running in a .bat 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 ($).