Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fso - open directories and copy contents
Message
From
05/02/2014 15:14:47
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01593241
Message ID:
01593332
Views:
25
Fantastic - Borislav

this new sort you provided actually landed in the middle of the dates - don't know why that is.
ASORT(ladir,3,-1,1,1)
So I opted for version two which works beautifully. I understand the what you did reading it as code - very clever

many many thnks
karen


>>>>I'm not getting very far with this. Can anyone please lend a hand and fill in the blanks where they can
>>>>I have a vault full of backup directories each start with FP and end with date and time reference.
>>>>I want to access the latest directory in the group - open the directory and copy all the files within to a temp directory
>>>>then move to the next directory and do the same.
>>>>
>>>>Here is what I have - in over my head here I'm afraid - thanks for any help.
>>>>k
>>>>
>>>>fso = CREATEOBJECT("Scripting.FileSystemObject")
>>>>lnNum =adir(ladir,'c:\vault\FP*','D')  &&& 'Directory names that start with FP
>>>>	asort(ladir,3)  &&& XXX i need reverse sort so that latest directory shows up first
>>>>
>>>>	for each ladir in 'c:\vault'  &&& XXX  go through each directory
>>>>
>>>>        open directory ???
>>>>    
>>>>	FSO.CopyFile()  &&& copy all files in directory to c:/temp 
>>>>	
>>>>endfor
>>>>
>>>
>>>
>>>lnNum =adir(ladir,'c:\vault\FP*','D')  && 'Directory names that start with FP
>>>asort(ladir,3)                         && XXX i need reverse sort so that latest directory shows up first
>>>FOR EACH lcdir IN ladir                && XXX  go through each directory
>>>    lcSource = ADDBS(lcdir)+"*.*"
>>>    COPY FILE (lcSource) TO "c:\temp\*.*"
>>>ENDFOR
>>>
>>>
>>>NOT TESTED!
>>
>>Thanks Borislav
>>I have tinkered with your solution (which was great by the way) and found I needed to define the new directory. Thus added it works in copying the files in that directory. The only remaining task is to reverse the order. Any ideas on how to do that. I can only find asort(ladir,3) option for date sort which yields oldest files first. I need the newest directory to start the list. Many thanks. K
>>
>>
>>nwdir='c:\vault\'
>>lnNum =adir(ladir,'c:\vault\FP*','D')  && 'Directory names that start with FP
>>asort(ladir,3)                         && XXX i need reverse sort so that latest directory shows up first
>>FOR EACH lcdir IN ladir               
>>      lcSource = nwdir+ADDBS(lcdir)+"*.*"
>>    COPY FILE (lcSource) TO "c:\temp\*.*"
>>ENDFOR
>>
>
>
>
>
>Two choices:
>
>...
>ASORT(asd,3,-1,1,1)
>...
>
>
>or:
>
>nNum =adir(ladir,'c:\vault\FP*','D')  && 'Directory names that start with FP
>asort(ladir,3)                         && XXX i need reverse sort so that latest directory shows up first
>FOR lnFor = nNum TO 1 STEP -1 
>    IF NOT LEFT(ladir[lnFor,1],1) == "."
>       lcSource = nwdir+ADDBS(ladir[lnFor,1])+"*.*"
>       ...
>    ENDIF
>NEXT
>
Previous
Reply
Map
View

Click here to load this message in the networking platform