Get width or height and add it to file's name with PowerShell ?
Message
Author
Hi, for some videos, I'd like to add their width or height in their file's name but I can't figure out how to make it (if possible) with PowerShell. I know that some metadatas are usable to be added in file's name ; this batch command line works to add the "last modification date" at the end of all file's name in a folder ; Code:
RE: Get width or height and add it to file's name with PowerShell ?
Hello, I do such stuff all the time with simple batch files and the CLI version of MediaInfo. Please tell me your desired target file name format, and I will hack something together for you. I suppose you want the capability to do this for all video files in a folder. Do you want to delete the original files and just keep the renamed files, or do you want to keep the original files, too? Cheers manolito
RE: Get width or height and add it to file's name with PowerShell ?
Alright, I'll do it later tonite... :) Fortunately I don't need to do this from scratch, I can reuse most of the code. But I just started to do my tax return for last year, I don't want to interrupt this right now.
RE: Get width or height and add it to file's name with PowerShell ?
No problem, I'm not in a hurry. Actually, I believe that i don't need to keep the original files ; that's only a name change after all, not a re-encoding.
RE: Get width or height and add it to file's name with PowerShell ?
Alright, here we go: Extract the 2 files into a folder of your choice, then drag & drop (or copy & paste) the source file(s) on the "Rename_Resolution.bat" file. Some notes: The "Rename_Resolution.bat" file works like a droplet. Highlight one or many source files from a folder and drag & drop them on the batch file. You can also create a link to the batch file on your desktop to make it easier. By default the source files are renamed. You can edit the batch file to change the default behavior to copying the source files. I used the older MediaInfo version 18.05. Zenitram changed the interface considerably after this version. I have no idea if newer versions will work, try it for yourself. You can easily expand the renaming capabilities by adding additional MediaInfo properties (like frame rate or aspect ratio). The MediaInfo CLI download comes with comprehensive documentation about the supported file properties. Cheers manolito
--------------------------------------------- Cosmos 95, with other "stuff"
RE: Get width or height and add it to file's name with PowerShell ?
Thanks, this works well ! This gives me an idea : is there a way to add an i (for interlaced) or a p (for progressive) after the resolution (without space) ? :o 1280.720p, 720.576i ... It's not that important but that would be cool ;) :thanks:
RE: Get width or height and add it to file's name with PowerShell ?
Great! :thanks: I noticed a strange thing with one avi file : the resolution has been added but the end of the name was erased :confused: But I tested with your second version, no more problem :) I still have a request :o : sometimes, there is no information about scan type and nothing is added after resolution. As it probably means in (nearly) all cases that it's progressive, could you add a "p" at the end anyway ? ;)
RE: Get width or height and add it to file's name with PowerShell ?
Ok, but if it's MBAFF, we could maybe add in the script ; IF !%type%==!MBAFF SET type=i and "if no scan type, set p" (but I don't know how to make it).
--------------------------------------------- Mods: TCK d/a Coilovers, RG4 Monolites wrapped in 273/30/19 Dunlop SP Sport Maxx, Dinan Exhaust, Dinan 3.91 LSD, Dinan Rear Strut Brace, Turner Rear Sub-Frame Reinforcement Kit, Brembo GT 4 Wheel Kit. reaktorcorps...since last thursday The Photograph