rename file based on folder name

Started by kspear, January 18, 2018, 11:20:08 PM

Previous topic - Next topic

kspear

For reasons i don't recall, i have several 3gp files that have no datetaken value and the createdate was simply when i copied to an external drive recently. So the current values of all the date attributes are wrong. But i do have a consistent folder naming structure where the current folder ends with yyyy-mm-dd. So i am able to generate a date variable from that string. I've looked at other newbie rename posts, but they all use the file dates to rename. I cannot figure what the syntax for using a variable would be. Here's what i have so far....

I start by copying the BAT file into the specific folder. The BAT grabs the path and builds the date variable.  The exiftool make makes the tmp files but never writes the date value. If i remove the extension flag, the BAT does change the datetaken for JPG but still doesn't modify the 3gp. Ideas?



SET DIR=%CD%

SET InputYear=%DIR:~33,4%
SET InputMonth=%DIR:~38,2%
SET InputDay=%DIR:~41,2%

SET InputDate="%InputYear%:%InputMonth%:%InputDay%"
SET InputTime="%InputMonth%:%InputDay%:00"

echo %InputDate%
echo %InputTime%

exiftool -all= -filename<"%InputYear%_%InputMonth%_%InputDay%.%le" -r -ext 3gp "%DIR%" -overwrite_original -k



Also, all of these specific date folders have one parent folder and there many date folders. It would be great to run this at the parent level, but i have no idea how to grab the subfolder value within the BAT portion of the commands.

Thanks for any help
Kevin

Phil Harvey

Hi Kevin,

ExifTool has only limited ability with 3gp files.  The only type of metadata it can add is XMP.

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

StarGeek

Are there any other numbers in the full path that match the pattern ####-##-## ?

If not you can use
exiftool -r -ext 3gp "-filename<${directory;s/(\d{4})-(\d\d)-(\d\d)/$1_$2_$3/}.%le" DIR
to do the rename, though you might want to look into %c in case there is more than one file in a directory.  This command will recurse into subdirectories.
* 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

@stargeek: thanks.  I obviously missed the point.

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

StarGeek

Not completely, the question is about setting a time stamp and the %InputTime% variable is created but never used.
* 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).