Assuming that you are on SQL server 2017 or higher, you can use the new dmv instead of DBCC LOGINFO. You can query that to find out which file(s) has no used VLFs. Based on that (using a cursor to loop the result from the query) you can generate the command to delete the file and execute that command using dynamic SQL. Not particular difficult T-SQL programming. Here's the query that your cursor will use, to get you started:
SELECT
file_id
,SUM(CAST(vlf_active AS tinyint)) AS status_of_file
FROM sys.dm_db_log_info(DB_ID())
GROUP BY file_id