Results 1 to 4 of 4

Thread: Help with moving files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    64

    Help with moving files

    This may be a silly question and it may not be possible but I think i remember seeing something that would work. I am trying to create a program that sorts files on one of the computers at work. I Work at a callcenter and we record the calls onto one main computer. The main computer puts them all into one folder. All I have so far is a program set up on a timer that Creates a folder of todays date if it doesnt exist. Now what I need to do next may be the impossible part. I need to move the files into folders per agent. The files look like this (example):

    DerrickR-1278162818_2008-7-16.ccr
    DerrickR-1278162420_2008-7-16.ccr
    SherryK-1278162637_2008-7-16.ccr
    MikeW-1278362420_2008-7-16.ccr
    MagnumG-74892017281_2008-7-16.ccr

    Is there a way to only use the characters up untill the first hyphen to create a folder for the agent by those characters say "DerrickR" and move the files into it?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    64

    Re: Help with moving files

    If this can be done I would prefer to use it this way. However if I have to use a txt file with the names like

    DerrickR
    SherryK

    I can put all the agents names in a txt file and update it when needed.

    How do i use the lines from a txt file?

  3. #3
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Indiana
    Posts
    295

    Re: Help with moving files

    Not sure I understand completely, but if your question is how to get just the 'name' part of the file, just use the InStr function.

    Set a variable and have it read your filename, such as DrrrickR-1234567 etc.

    Use InStr to get just the name part (everything before the dash), then use that to create your folder.

    Code:
    dim LongName as string
    dim ShortName as string
    
    LongName="DerrickR_123456678-2008-7-16.ccr"
    ShortName = left(LongName,InStr(LongName,"_")-1)
    
    'in this case ShortName = "DerrickR" so use that to create your folder
    InStr finds the position of the underscore in the LongName. In this example it would be at position #9. So the ShortName is simply the first 8 characters of the long name. Basically then it's = Left(LongName,8) since InStr(LongName,"_")-1 = 9 - 1 = 8

    Now since you don't want to duplicate "DerrickR", you might write that to an Array. Then when you calculate new names, first compare them to the names in the Array, and create the file only if it doesn't already exist.

    If you'll be running the program daily and some files names may already exist, and you don't want to duplicate them, then you can't use the array idea. In that case you could do one of two things.

    1. Have a text file which lists all your currently used folder names and compare to those names first, or
    2. Just check to see if a folder by that name already exists before you create a new one.

    BTW, not sure how you're naming the original files, but I suggest you use leading zeroes in the date portion, for example: 2008-07-03.ccr

    Hope this helps
    Last edited by Caskbill; Jul 16th, 2008 at 08:36 PM.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2006
    Posts
    64

    Re: Help with moving files

    I can't change how the date file is made. I didnt program the dialing software. Im just trying to make a program to clean up the mess and arrange the recordings.

    With:

    Code:
    dim LongName as string
    dim ShortName as string
    
    LongName="DerrickR_123456678-2008-7-16.ccr"
    ShortName = left(LongName,InStr(LongName,"_")-1)
    Is there a wildcard I can use with this. There are different names starting before the _ and some names are longer than other. Some people have names that are as simple as TomR and some as complex as HakeemL

    I need it to group the files and put them in a folder by the persons name. I cant specify a longname because it wont get everyone that way. heeeeeeeeeeelp me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width