>>>>>>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)
>>> 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
>
>You messed paths:
>Here SYS(2000,"c:\citisprint\sttach\*.*")
>you read "c:\citisprint\sttach\*.*"
>BUT few lines after that you read "c:\citisprint\attach\"
>lcFileName = SYS(2000,"c:\citisprint\attach\*.*",1)
>Also you must put the path when you rename file:
>
>RENAME (path to the file + lcFileName) TO ("c:\citisprint\attachxls\"+lcFileName)
>
I have corrected the typo
my code now is - what should it be
SET DEFAULT TO c:\citisprint\attach
lcFileName = SYS(2000,"c:\citisprint\attach\*.*")
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
I dont understand your rename exactly - could you possible just correct all the code so that I have it exactly
The file name doesnt change only the directory where the object of my code is to move the first file from the first directory to the second directory every time this cod is run
Thanks for all your help so far
Specialist in Advertising, Marketing, especially Direct Marketing
I run courses in Business Management and Marketing