Get width or height and add it to file's name with PowerShell ? >> FORUM
Forums

Forums



SearchSearch   Users   Registration   Entrance
Today: 18.01.2026 - 13:00:46
Pages:  1  2  

Get width or height and add it to file's name with PowerShell ?

MessageAuthor

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:




325ic

users main


Statistics:
Messages: 250
Registration: 10.06.2003
25.04.24 - 07:26:38
Message # 1
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




ZLUJ

users main


Statistics:
Messages: 4,686
Registration: 09.14.2003
25.04.24 - 07:38:18
Message # 2
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.




whoadude

users main


Statistics:
Messages: 23
Registration: 04.16.2003
25.04.24 - 07:46:26
Message # 3
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.




melmyers12

users main


Statistics:
Messages: 413
Registration: 11.13.2001
25.04.24 - 07:51:43
Message # 4
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"

MELSM3

users main


Statistics:
Messages: 191
Registration: 10.13.2003
25.04.24 - 07:55:10
Message # 5
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:


---------------------------------------------
.....

sfhighroller

users main


Statistics:
Messages: 87
Registration: 05.14.2002
25.04.24 - 07:59:56
Message # 6
RE: Get width or height and add it to file's name with PowerShell ?

Sure, no problem... :p




Low Level

users main


Statistics:
Messages: 2,867
Registration: 09.19.2002
25.04.24 - 08:04:32
Message # 7
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 ? ;)




polo12345

users main


Statistics:
Messages: 986
Registration: 10.03.2002
25.04.24 - 08:12:33
Message # 8
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

truth

users main


Statistics:
Messages: 193
Registration: 06.19.2003
25.04.24 - 08:22:34
Message # 9
RE: Get width or height and add it to file's name with PowerShell ?

OK, check out this one: For MBAFF and PAFF it will report "i", if there is no ScanType it will report "p".




Aren G

users main


Statistics:
Messages: 2,533
Registration: 07.04.2002
25.04.24 - 08:29:13
Message # 10
RE: Get width or height and add it to file's name with PowerShell ?
HP & Compaq AMD 64 Notebooks : Previous topicNext topic: post production plugins
Pages:  1  2  

The administrator has prohibited guests from replying to messages! To register, follow the link: register


Participants