Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Count files & move them!

Posted on 2006-04-05
10
Medium Priority
?
181 Views
Last Modified: 2010-04-23
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.

0
Comment
Question by:plenahan
  • 5
  • 3
  • 2
10 Comments
 
LVL 9

Accepted Solution

by:
CDCOP earned 2000 total points
ID: 16388344
'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
 
LVL 3

Expert Comment

by:mazkot
ID: 16388641
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
 
LVL 9

Expert Comment

by:CDCOP
ID: 16388982
There is nothing wrong with my code.

So please explain why YOU think it is 'wrong'
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Expert Comment

by:CDCOP
ID: 16388996
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
 
LVL 3

Expert Comment

by:mazkot
ID: 16389215
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
 
LVL 9

Expert Comment

by:CDCOP
ID: 16391332
So what makes this any different than my code?
0
 

Author Comment

by:plenahan
ID: 16393450
I'm checking the code today and will let you know my answer soon. :)
0
 
LVL 3

Expert Comment

by:mazkot
ID: 16394495
i was already thinking about sample2 when I made the post...
0
 

Author Comment

by:plenahan
ID: 16395881
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
 
LVL 9

Expert Comment

by:CDCOP
ID: 16396021
No problem.

Thanks for points and grade.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question