Created
September 6, 2020 11:16
-
-
Save farshidhss/d0a725c8b98900af1d59f0ada3e81ec8 to your computer and use it in GitHub Desktop.
Add filename to the title metadata for all video files in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/zsh | |
| for entry in *."$1" | |
| do | |
| Filename=${entry%.*} | |
| echo "setting title -> " $Filename | |
| FileTitle=$(exiftool -s -Title "$entry" | awk '{print $3}'); | |
| echo "file title: " $FileTitle | |
| if [ "$FileTitle" = "$Filename" ]; then | |
| echo "File title is the same as filename, skipping..." | |
| else | |
| exiftool -P -overwrite_original -Title="$Filename" $entry | |
| fi | |
| done |
Author
But how can this be done? I copy exiftool to the files folder, I run it and the black CMD window opens, but it doesn't let me execute any command...
I'm trying to batch write the Title in the metadata from the file names for a few MP4 video files... I'm doing it now with Mp3tag, but I still would like to know how to do it with exiftool.
Thank you.
Author
I suggest first open a terminal session and go to the folder where your files are stored. Then just test to see if exiftool actually runs inside your folder. If it did run then do a chmod +x setTitleFromFilename.sh to be able to execute the script then run the command ./setTitleFromFilename.sh mp4
- make sure you have backup of your files just in case anything goes wrong.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This needs exiftool which can be downloaded from https://exiftool.org/
Call this file inside a folder with all your video files with the extension of the files. For example, if extension is mp4 then run:
-> ./setTitleFromFilename.sh mp4
Should also work for any other type of file that has Title in metadata.