Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Code to find files not in a list

- - - - -

  • Please log in to reply
13 replies to this topic

#1
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

I'm looking to do the opposite of this....

FOR %%i IN (
WindowsXP-KB2756822-x86-ENU.exe
WindowsXP-KB2761226-x86-ENU.exe
WindowsXP-KB2761465-x86-ENU.exe
WindowsXP-KB2778344-x86-ENU.exe
WindowsXP-KB2779030-x86-ENU.exe
WindowsXP-KB2792100-x86-ENU.exe
WindowsXP-KB2797052-x86-ENU.exe
WindowsXP-KB2799329-x86-ENU.exe
WindowsXP-KB2799494-x86-ENU.exe
WindowsXP-KB2808735-x86-ENU.exe
WindowsXP-KB2809289-x86-ENU.exe
WindowsXP-KB2817183-x86-ENU.exe
) DO (IF EXIST %%i echo %%i exists)

In other words, if there are some files that are not in the list, output something like echo %%i is and unknown file. Ask yourself why you need this.

I suppose the only way to do this is with a dir /b>updates.txt or using OR's?

Thanks!

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!



How to remove advertisement from MSFN

#2
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,397 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
What about forfiles? :unsure:
http://ss64.com/nt/forfiles.html

jaclaz

#3
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

Thanks but it's for my UDC script and I can't redistribute MS binaries. I looked at the page and still don't see a way to do it with it.

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


#4
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
  • Joined 13-January 06
Why not use "findstr /V" as it will show everything except the pattern ?

#5
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,282 posts
  • Joined 14-September 05
  • OS:none specified
  • Country: Country Flag
To be clear... The purpose is to notify/move any/all items NOT in your "standard download/build" list? I say that because I noted some IE7 Updates (among others) in your UDC script. You wish to "generically" eliminate any/all "OTHER" files? :unsure:
I noted a tendency of some users of your Script to "include" stuff that should NEVER have been there and then wondered "gee, why did it fail?"... (still :unsure:)

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#6
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • Joined 02-August 03
  • OS:none specified
  • Country: Country Flag
Are you trying to exclude certain updates from being installed?


GunSmokingMan



#7
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

To notify them that they are there and ask them to investigate further. I wont move them because of other add-ons they may add but way too many times they include crap updates. All they need are my updates.

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


#8
jumper

jumper

    2014 All-American Masters HJ'er

  • Member
  • PipPipPip
  • 476 posts
  • Joined 21-January 11
  • OS:98SE
  • Country: Country Flag
I like recursive batch files:
@echo off
if %1*==* goto NOPARAM

::Only list unapproved updates
if %1==WindowsXP-KB2756822-x86-ENU.exe goto END
if %1==WindowsXP-KB2761226-x86-ENU.exe goto END
echo  %1
goto END

:NOPARAM
echo Approved updates:
if exist WindowsXP-KB2756822-x86-ENU.exe echo  WindowsXP-KB2756822-x86-ENU.exe
if exist WindowsXP-KB2761226-x86-ENU.exe echo  WindowsXP-KB2761226-x86-ENU.exe
echo.
echo Unapproved updates:
lfnfor on
for %%i in (WindowsXP-KB*.exe) do call %0 %%i

:END

Update
Another version that also lists missing files:
@echo off
set k1=KB2756822 KB2761226 KB2761465 KB2778344 KB2779030 KB2792100
set k2=KB2797052 KB2799329 KB2799494 KB2808735 KB2809289 KB2817183
if %1*==* goto NOPARAM

::Only list unapproved updates
for %%f in (%k1%) do if %1==WindowsXP-%%f-x86-ENU.exe goto END
for %%f in (%k2%) do if %1==WindowsXP-%%f-x86-ENU.exe goto END
echo  %1
goto END

:NOPARAM
echo Approved updates:
for %%f in (%k1%) do if exist WindowsXP-%%f-x86-ENU.exe echo  WindowsXP-%%f-x86-ENU.exe
for %%f in (%k2%) do if exist WindowsXP-%%f-x86-ENU.exe echo  WindowsXP-%%f-x86-ENU.exe
echo.
echo Missing updates:
for %%f in (%k1%) do if not exist WindowsXP-%%f-x86-ENU.exe echo  WindowsXP-%%f-x86-ENU.exe
for %%f in (%k2%) do if not exist WindowsXP-%%f-x86-ENU.exe echo  WindowsXP-%%f-x86-ENU.exe
echo.
echo Unapproved updates:
lfnfor on
for %%i in (WindowsXP-KB*.exe) do call %0 %%i

:END

Edited by jumper, 22 May 2013 - 04:10 AM.

Design feedback requested:
IHAtool - IpHlpApi tester; call various functions and report results
--status-> framework is solid; 22 api's fully supported; preview release coming soon
ComDlg32 wrapper - ComDlgEx meets IpHlpApi wrapper
--status-> PrintDlgExW working in latest SumatraPDF 8^)
Future projects: ImportPatcher40 - dialog interface; Kexter - IP40+Ktree+Kexstubs

#9
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

Some of them are named IE8-WindowsXP-KB* so can I just do
for %%i in (WindowsXP-KB*.exe OR IE8-WindowsXP-KB*.exe) do call %0 %%i

?

Also "lfnfor on" is a non recognized command.

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


#10
jumper

jumper

    2014 All-American Masters HJ'er

  • Member
  • PipPipPip
  • 476 posts
  • Joined 21-January 11
  • OS:98SE
  • Country: Country Flag
>Some of them are named IE8-WindowsXP-KB* ...
Try
for %%i in (WindowsXP-KB*.exe IE8-WindowsXP-KB*.exe) do call %0 %%i
-or-
for %%i in (*WindowsXP-KB*.exe) do call %0 %%i

>Also "lfnfor on" is a non recognized command.
You can remove it. LFNFOR is only needed to enable long-file-name support in the FOR command on pre-NT versions of Windows and DOS.

This code should also work for all versions:
cd.>lfnfor.bat
lfnfor on
del lfnfor.bat

Design feedback requested:
IHAtool - IpHlpApi tester; call various functions and report results
--status-> framework is solid; 22 api's fully supported; preview release coming soon
ComDlg32 wrapper - ComDlgEx meets IpHlpApi wrapper
--status-> PrintDlgExW working in latest SumatraPDF 8^)
Future projects: ImportPatcher40 - dialog interface; Kexter - IP40+Ktree+Kexstubs

#11
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,534 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

allen2 has already pointed you with the obvious solution, FINDSTR /V.

As long as you have a local file listing Your updates, lets call it MyList.txt, then the following should suffice:
@FOR /F "TOKENS=*" %%# IN ('DIR/B *WINDOWSXP-KB*.EXE^|FINDSTR/VG:MYLIST.TXT') DO @ECHO/%%# IS NOT FROM MY LIST!


#12
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

Thanks all!

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


#13
-X-

-X-

    Member

  • Patrons
  • 2,412 posts
  • Joined 08-January 04
  • OS:XP Pro x86
  • Country: Country Flag

Donator

allen2 has already pointed you with the obvious solution, FINDSTR /V.

As long as you have a local file listing Your updates, lets call it MyList.txt, then the following should suffice:

@FOR /F "TOKENS=*" %%# IN ('DIR/B *WINDOWSXP-KB*.EXE^|FINDSTR/VG:MYLIST.TXT') DO @ECHO/%%# IS NOT FROM MY LIST!


I found a quirk. If I have WindowsXP-KB2564958-X86-ENU.exe (capital x) in mylist.txt and have WindowsXP-KB2564958-x86-ENU.exe as my file then it flags it as not in the list. Any way to make it case insensitive? Strange because
WINDOWSXP-KB from the code is not the same as the updates which use WindowsXP-KB and they are not flagged.

Thanks.

EDIT: I found the /i switch, ( /I Specifies that the search is not to be case-sensitive.) but when I do FINDSTR/VGI, I get this.

D:\Profile\Desktop\WUD
FINDSTR: /G ignored
FINDSTR: /: ignored
FINDSTR: /u ignored
FINDSTR: /d ignored
FINDSTR: /a ignored
FINDSTR: /t ignored
FINDSTR: /. ignored
FINDSTR: /t ignored
FINDSTR: /t ignored
FINDSTR: Bad command line

EDIT2: Duh! I changed it to FINDSTR/VIG:updates.txt and all is well!

Edited by -X-, 07 June 2013 - 09:40 PM.

Download all Windows XP Post SP3 High-Priority Updates with a simple double click @ xdot.tk post-12166-0-42859000-1399044129.png ]
               If someone helps you fix a problem, please report back so they and others can benefit from the solution. Thanks!


#14
Yzöwl

Yzöwl

    Wise Owl

  • Super Moderator
  • 4,534 posts
  • Joined 13-October 04
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

Well done for trying different options, solving your problem and letting us know the outcome.

I didn't include the case insensitive switch because I figured you would have created MyList.txt directly from your master directory which I expected would contain file names in the correct case. I fgured that Microsoft would of course maintain that case throughout their various language versions of each update. A better option would be to have a MyList.txt which contains only the seven digit Knowledge Base numbers, KBnnnnnnn.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN