Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy latest files only
Message
De
11/10/2012 12:45:00
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01554753
Message ID:
01554802
Vues:
36
Given your original question, this should work
lcOriginalPath = 'c:\post\temp'
lcNewPath = 'c:\myzipfolder'
lnNum =adir(laDir,Forcepath(lcOriginalPath,'*.prg')) && Remove the 'D' part!
FOR nCount = 1 TO lnNum
   if date() - laDir(nCount,3)<30 && newer than 30 days
      *? LADIR(nCount,1)+" copied "
      Copy File (Forcepath(lcOriginalPath,laDir(nCount,1))) To  (Forcepath(lcNewPath,laDir(nCount,1)))
   endif
ENDFOR
>thanks tore - i am actually using a creation (I thought was yours - could be wrong) but i didn't quite know how to adapt it for the new files - what i've done is left it as is to remove all program files except the last 50 most recent. i'm ok with that and it is working. but i would like to know if there is a simple way of adapting the code so that it erases all but the files in the last 30 days instead of all but the last 50 files. here is what i'm using - if it's too complicated leave it Tore, but if it's a simple line or two i'm missing i would would be grateful for the method to see how it's done.
>
>fso = CREATEOBJECT("Scripting.FileSystemObject")
>lnNum =adir(ladir,'c:\post\temp\*.prg','D')
>asort(ladir,3) 
>FOR nCount = 1 TO lnnum-50 && Loop for number of programs
>  		*? LADIR(nCount,1)+" Erased "
>		fso.DeleteFile("c:\post\temp\&ladir(nCount,1)")
>ENDFOR
>
>k
>>Use Adir() to create an array of all the files in the directory. Then you scan the array and copy every file which are newer than 30 days.
>>
>>>in order to keep user computers up to date i zip the complete array of program files into a directory then send them along as zip attachment in email.
>>>problem is i have been sending the whole lot each time. what i want to do is just send the programs that have only been changed within the last month
>>>
>>>current command is the basic copy
>>>
>>>Copy File c:/myfolder/*.prg To c:\myzipfolder
>>>
>>>a) how would i modify this command to skip over programs that show no change within last 30 days
>>>or
>>>b) would it be better to copy all then sort by date in the zip directory then delete those older ones.
>>>
>>>thanks for your help
>>>
>>>k
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform