KNARZ Posted February 9, 2005 Share Posted February 9, 2005 hican someone help me to write a short batchfile which:rename the WindowsXP-KBXXXXX-x86-XXX.exe files to:KBXXXXXX.EXEand than export the files(names) to something like this...%CMD% %SOURCE%KBXXXXXX.EXE %INT%%PATH%To explai what the var. means:SET CMD=START /WAITSET INT=/Q -INTEGRATE:SET SOURCE=H:\UPDATES\SET PATH=H:\XPCD\_________rename WindowsXP-*-x86-XXX.exe KB*.EXEdoesn't work... i thought that should work... but no way... _________i want a batch... that rename the files and export it with parameters in the beginning of the file and in the end similar example;WindowsXP333.exetoWIN333.EXEand export (text)file:like this one...PAR1 WIN333.EXE PAR2XXX means the KB number and/or language... Link to comment Share on other sites More sharing options...
Wireless Posted February 10, 2005 Share Posted February 10, 2005 This should get you started. It will rename the hotfixes that are in the %SOURCE% directory and output a list to export.txt in your format.SET CMD=START /WAITSET INT=/Q -INTEGRATE:SET SOURCE=H:\UPDATES\SET PATH=H:\XPCD\del export.txt 2>nulfor /f "tokens=1,2 delims=-" %%I in ('dir /b %SOURCE%\windowsxp-kb*.exe') do ( ren %SOURCE%%%I-%%J*.EXE %%J.EXE echo %CMD% %SOURCE%%%J.EXE %INT%%PATH%>>export.txt) Link to comment Share on other sites More sharing options...
KNARZ Posted February 10, 2005 Author Share Posted February 10, 2005 really thanks... i had to modified something because of the '(' and ')' but now:the renaming works perfect... but exporting not that good...i modified a little bit more (as i can understand the soruce gg)to:DEL EXPORT.TXT 2>NULFOR /F "TOKENS=1,2 DELIMS=-" %%I IN ('DIR /B WINDOWSXP-KB*.EXE') DO REN %%I-%%J*.EXE %%J.EXEECHO %CMD% %SOURCE%%%J.EXE %INT%%PATH% >> EXPORT.TXTin exporting.txt the KBXXXX won't be insertedexport.txt put's out (only 1 line):START /WAIT H:\XXX\%J.EXE /Q -INTEGRATE:H:\XPCD\ Link to comment Share on other sites More sharing options...
Wireless Posted February 11, 2005 Share Posted February 11, 2005 The REN and ECHO lines need to be in parenthesis because they are both part of the DO loop. Enclosing lines in parenthesis like that is a way of executing multiple lines of code using commands like IF and DO. An alternative way is to us the '&' character to separate multiple commands like...FOR /F "TOKENS=1,2 DELIMS=-" %%I IN ('DIR /B WINDOWSXP-KB*.EXE') DO REN %%I-%%J*.EXE %%J.EXE & ECHO %CMD% %SOURCE%%%J.EXE %INT%%PATH% >> EXPORT.TXTThis must all be on one line. This way makes the code harder for someone else to read (if that matters) but it works all the same. Link to comment Share on other sites More sharing options...
KNARZ Posted February 14, 2005 Author Share Posted February 14, 2005 THX =) now i got it in that way that i wanted DEL EXPORT.TXT 2>NULECHO SET CMD=START /WAIT >> EXPORT.TXTECHO SET PAR=/Q -INTEGRATE: >> EXPORT.TXTECHO SET SOURCE=H:\XXX\ >> EXPORT.TXTECHO SET TO=H:\XPCD\ >> EXPORT.TXTECHO SET START=%%CMD%% %%SOURCE%% >> EXPORT.TXTECHO SET END=%%PAR%%%%TO% >> EXPORT.TXTECHO. >> EXPORT.TXTECHO Microsoft Security Bulletin Summary für %date:~3,-5% / %date:~-4% >> EXPORT.TXTECHO. >> EXPORT.TXTFOR /F "TOKENS=1,2 DELIMS=-" %%I IN ('DIR /B WINDOWSXP-KB*.EXE') DO REN %%I-%%J*.EXE %%J.EXE & ECHO %%START%%%%J.EXE %%END%% >> EXPORT.TXTECHO. >> EXPORT.TXTECHO Erstellt am: %date% um %time:~0,-6% >> EXPORT.TXT Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now