ECHO OFF

SETLOCAL EnableDelayedExpansion

set include=*.log

FOR /L %%i IN (1,2,3) DO (

    net use i: \\my-server%%i\d$\IISLogs

    FOR /R i:\ %%G IN (%include%) DO (

        XCOPY %%G D:\ServerLogsAndBackups\IIS\w%%i\
    )
7z a -t7z D:\ServerLogsAndBackups\IIS\w%%i\files%%i.7z *.log -mx9

net use i: /delete

)

 

using the code above, I want to insert the folder i'm currently in in %%G into the filename that is put in to destination in the xcopy. 

 

So it might be coming from: i:\w3svc98435783475\ex110430.log and i want it to end up as D:\ServerLogsAndBackups\IIS\w1\w3svc98435783475_ex110430.log

 

anyone got any ideas?