Count files & move them!

I have a program that splits tif files wonderfully but, my concern is this. I have a folder called c:\shipping with  a lot of tif files numbered from 001.tif to whatever, like 0150.tif.
Example
001.tif 9kb
002.tif 27kb
003.tif 26kb
004.tif 27kb
005.tif 22kb
006.tif 9kb
007.tif 27kb
008.tif 15kb
009.tif 10kb
010.tif 20kb
011.tif 10kb
012.tif 16kb

First we know if the file is <= 10 kb this is a blank page that seperates one invoice from another.
What I need is the first page of every invoice moved to c:\test
Must read each tif in numerical order.
The result would be file# 002.tif, 007.tif, 010.tif, 012.tif and  so on to the end.
Needed to be coded in vb.net and this is urgent.

plenahanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CDCOPCommented:
'CDCOP
        Dim lngDirSize As Long
        Dim objFileInfo As System.IO.FileInfo
        Dim objDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\shipping")
        Dim Movenext As Boolean

        For Each objFileInfo In objDir.GetFiles()
            lngDirSize = objFileInfo.Length

            If Movenext = True Then
                System.IO.File.Move(objFileInfo.FullName, "c:\test\" & objFileInfo.Name)
            End If

            If lngDirSize <= 10000 Then
                Movenext = True
            Else
                Movenext = False
            End If

        Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mazkotCommented:
just gonna re-arrange  cdcop code to make it right..

CDCOP
        Dim lngDirSize As Long
        Dim objFileInfo As System.IO.FileInfo
        Dim objDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\shipping")
        Dim Movenext As Boolean

        For Each objFileInfo In objDir.GetFiles()
            lngDirSize = objFileInfo.Length

            If lngDirSize <= 10000 Then
                Movenext = True
            Else
                Movenext = False
            End If

            If Movenext = True Then
                System.IO.File.Move(objFileInfo.FullName, "c:\test\" & objFileInfo.Name)
            End If
         Next
0
CDCOPCommented:
There is nothing wrong with my code.

So please explain why YOU think it is 'wrong'
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

CDCOPCommented:
The way I read the author's text, your rearranging of my code is actually wrong.

Files <= 10k are a seperator page
The NEXT page starts the invoice and 'What I need is the first page of every invoice moved to c:\test'
So that page should be moved to the folder, not the blank seperator pages.
0
mazkotCommented:
sorry.. about my lack of explanation.. and my mind was moving to fast that i forgot  to ask plenahan, if a separator page is default as start of your directory(sample 1)  or sometimes it starts with the first page(sample 2)?

sample1:
001.tif <10kb--> separator page /(starting file)
002.tif >10k --> 1st page/next page

Sample2:
001.tif >10kb--> 1st Page /(starting file)
.....
00x.tif  <10k --> separator page
00y.tif >10kb--> nextpage

and after re-checking what I did.. i also forgot to add something.. here i'm really sorry...
Here updated and working
       
       Dim lngDirSize As Long
        Dim objFileInfo As System.IO.FileInfo
        Dim objDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("C:\shipping")
        Dim Movenext As Boolean= False
        Dim FirstPage As Boolean= False

        For Each objFileInfo In objDir.GetFiles()
            lngDirSize = objFileInfo.Length

            If lngDirSize <= 10000 Then
                Movenext = True
            Else
               
            if Movenext=True then
             FirstPage=True
            else
            FirstPage=False
            End if
            Movenext = False
               
            End If

            If Movenext = False and FirstPage= True Then
                System.IO.File.Move(objFileInfo.FullName, "c:\test\" & objFileInfo.Name)
            End If
         Next

and again I'm totally sorry cdcop...
0
CDCOPCommented:
So what makes this any different than my code?
0
plenahanAuthor Commented:
I'm checking the code today and will let you know my answer soon. :)
0
mazkotCommented:
i was already thinking about sample2 when I made the post...
0
plenahanAuthor Commented:
I ran the test on 150 pages and it did what I asked for. Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!   :)
Only get the first page of every invoice. thanks

Your the man cdcop.
0
CDCOPCommented:
No problem.

Thanks for points and grade.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.