You are not logged in.
How do I get an extension if the filename has two dots?
ex.
Test.aaa.txt
%~r1 -> aaa.txt
Please help me
Offline
Why would .aaa.txt be the extension instead of just .txt? What if you had A.File.Name.Like.This.2020.HEVC.x265.mkv?
Also, %~r doesn't work because %~r isn't a valid variable substitution command. %~x gets the extension.
Offline
You'll have to process the file name as a parameter twice to do what you want. In the simplest case (where you want only two "extensions"), you could do this:
set primary_ext="%~1"
for %%A in ("%~n1") do set secondary_ext="%%~xA"
set combined_ext="%secondary_ext%%primary_ext%"
I believe this should be "safe" for use where there is only one extension (or none at all).
If you wanted further extension depth, it should be fairly straight forward to adapt this into a loop mechanism.
Last edited by bluesxman (18 Aug 2020 09:00)
cmd | *sh | ruby | chef
Offline