|
-
Jul 16th, 2008, 08:23 PM
#3
Hyperactive Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|