Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying files to another directory
Message
 
To
09/11/2016 11:00:18
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01642909
Message ID:
01642965
Views:
20
>>>>>>>>I have an unknown number of files in directory A
>>>>>>>>I want to copy just the first to another directory B
>>>>>>>>
>>>>>>>>My present code copies them all COPY FILE *.* to c:\citisprint\attachxls\latest.xlsx
>>>>>>>>
>>>>>>>>How do I just copy the first and then delete it so it doesn't get copied again or can I move the first file to directory B? If so how?
>>>>>>>>
>>>>>>>>Thanks
>>>>>>>
>>>>>>>
>>>>>>>How do you know what file is first?
>>>>>>
>>>>>>Say I have 10 files in a directory
>>>>>>
>>>>>>The first one in the directory - I want to move it to another directory process it and then delete it
>>>>>>
>>>>>>The next time I run the program the original 2nd file is now no !
>>>>>>
>>>>>>And so on until I have processed all 10 files
>>>>>>
>>>>>>Colin
>>>>>
>>>>>
>>>>>lcFileName = SYS(2000,"D:\test\*.*")
>>>>>DO WHILE NOT EMPTY(lcFileName)
>>>>>   RENAME ("D:\test\"+lcFileName) TO ("D:\NewFolder\"+lcFileName) && Be careful, this will MOVE file not just copy
>>>>>   lcFileName = SYS(2000,"D:\test\*.*",1)
>>>>>ENDDO
>>>>>
>>>>
>>>>
>>>>I have attemted to run the following code in my live program - the files are in the attach directory but nothing gets moved - waht am I doing wrong?
>>>>
>>>>
>>>>SET DEFAULT TO c:\citisprint\attach
>>>>
>>>>lcFileName = SYS(2000,"c:\citisprint\sttach\*.*")
>>>>DO WHILE NOT EMPTY(lcFileName)
>>>> RENAME (lcFileName) TO ("c:\citisprint\attachxls\"+lcFileName) && Be careful, this will MOVE file not just copy
>>>> lcFileName = SYS(2000,"c:\citisprint\attach\*.*",1)
>>>>ENDDO
>>>
>>>The files must be on the same drive for this code to work. If they are on separate drives, you must first copy the files, make sure that they are actually copied and then delete the old ones.
>>
>>Both directories are on the C drive
>>
>>c:\citisprint\attach
>>
>>c:\citisprint\attachxls
>
>lcFileName will only hold the file name.
>
>
RENAME (ForcePath(lcFileName,"c:\citisprint\attach")) TO (ForcePath(lcFileName,"c:\citisprint\attachxls"))
Ok maybe I am getting in a muddle - let me restate the problem from scratch

>>>>>>>>I have an unknown number of files in directory c:\citisprint\attach
>>>>>>>>I want to copy just the first to another directory c:\citisprint\attachxls with a file name of latest.xlsx

>>>>>>>>How do I move the first file to the second directory with the rename

when I run it again it does the same thing with the second file until all the files have been moved and processed

Is that clearer - thanks for all your help
Specialist in Advertising, Marketing, especially Direct Marketing

I run courses in Business Management and Marketing
Previous
Reply
Map
View

Click here to load this message in the networking platform