Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract all obj files from a lib

How can I extract all .obj files from a .lib file? The only way I found is to extract one at once. Is there a way to automate it?

LIB.EXE /EXTRACT:member.obj Library.LIB 
like image 750
John Lewis Avatar asked Dec 31 '14 22:12

John Lewis


1 Answers

This is the batch file that I ended up using with usage extract.bat mylib.lib or extract.bat *.lib even

@ECHO OFF
SETLOCAL EnableDelayedExpansion

:Loop
IF "%1"=="" GOTO Continue

FOR %%F in (%1) DO (

    SET LIBFILE=%%F
    SHIFT

    @ECHO !LIBFILE!

    FOR /F %%O IN ('lib.exe /LIST !LIBFILE! /NOLOGO') DO (
        @SET OBJFILE=%%O
        @ECHO !OBJFILE!
        
        SET OBJPATH=%%~dO%%~pO
        SET OBJNAME=%%~nO

        IF NOT EXIST "!OBJPATH!" md !OBJPATH!

        IF EXIST "!OBJFILE!" ECHO !OBJFILE! exists, skipping...
        IF NOT EXIST "!OBJFILE!" lib.exe /NOLOGO !LIBFILE! "/EXTRACT:!OBJFILE!" "/OUT:!OBJFILE!"
    )
)
GOTO Loop
:Continue
like image 68
GaspardP Avatar answered Oct 15 '22 07:10

GaspardP