×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

XCOPY-DOS type function with VFP

XCOPY-DOS type function with VFP

XCOPY-DOS type function with VFP

(OP)
Hi,

Is there a variant of the VFP "COPY FILE" command where I can copy files that have changed on or after the specified date ?

Example in DOS:
XCOPY *.*/D:m-d-y

Example in VFP:
COPY FILE /D or something of the sorts? What would be the paramters in VFP if any?

I don't see anything in the VFP HELP FILE.

Please let me know.


Thanks,
FOXUP !


RE: XCOPY-DOS type function with VFP

(OP)
Nevermind. I found it using FDATE...LOL.

Thanks everybody ;)

RE: XCOPY-DOS type function with VFP

Not with just COPY FILE. YOu could use ADIR() to retrieve info about the files in a folder and then loop through to find only the ones of interest.

Tamar

RE: XCOPY-DOS type function with VFP

(OP)
Hi All,

It seems there was a bug in my logic when I use "FDATE". This command does not yield the proper response:

COPY FILE R:\CDR\DES\deactivate_es_daily????????.dbf TO C:\QEns_Deacts for fdate>periods.pfrom

I've checked the fdate of the file and it's 26/04/2019. Ive checked the periods.pfrom, it's 01/05/2019, YET it gets copied ??? Im wondering if the "FOR" in the above statement doesn't get processed?

Please help with this one.


Thanks,
FOXUP!

RE: XCOPY-DOS type function with VFP

COPY FILE doesn'T have a FOR clause, COPY TO does, but that needs a workarea as source.

CODE

IF FDATE('whatever')>FDATE('somethingelse')
   COPY FILE whatever to somethingelse
ENDIF 

It's much more reliable to use xcopy or robocopy, though.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: XCOPY-DOS type function with VFP

No, your COPY FILE won't work, for two reasons. First, the command doesn't take a FOR clause. And secondly, if it did take a FOR clause, it still wouldn't work, because it would have no way of knowing that the date your are using is the file's date. Put another way, there is no connection between the COPY FILE command and the FDATE() function.

The only solution (as Tamar suggested) is to use ADIR() to get the dates of all the files that meet your specification into an array. You then loop through the resulting array, looking for those files with the required date condition. You then copy those files individually.

It's a little more complicated than using COPY FILE, but still only needs a few lines of code.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: XCOPY-DOS type function with VFP

(OP)
Thank you Olaf, I was just reading the exact HELP documentation and wasn't seeing any clause for it.

How can I duplicate this in an DOS-XCOPY command?

COPY FILE R:\CDR\DES\deactivate_es_daily????????.dbf TO C:\QEns_Deacts for fdate>periods.pfrom AND fdate<=periods.invoicedat+1


Any suggestions?


Thanks,
FOXUP

RE: XCOPY-DOS type function with VFP

(OP)
Hi Mike,

I understand but was hoping to achieve it thru XCOPY (Dos) or COPY FILE command (VFP) without the ADIR method.

can you assist in the DOS-XCOPY ?


Thanks,
FOXUP!

RE: XCOPY-DOS type function with VFP

Can you simple please reread? Yes, there is NO for clause. Right. You can't put a condition into the COPY FILE command. I gave you the code, an IF statement, which only does COPY FILE, when the filedate is newer.
You can't use a file name skeleton (with ? or *) for this, you have to loop all the single files.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: XCOPY-DOS type function with VFP

You've changed the spec. You originally asked about ccopying files that had changed after a certain date, which is easy with XCOPY. But now you want to copy files that have changed between two dates. As far as I know, that's not possible with XCOPY.

To copy files that have changed after a given date (periods.pfrom in this case), you would first have to convert the date to MM-DD-YYYY format, like so:

CODE -->

SET MARK  TO "-"
SET DATE AMERICAN
SET CENTURY ON
lcDate = DTOC(periods.pfrom) 

Then construct and run the XCOPY command:

CODE -->

lcCommand = "XCOPY R:\CDR\DES\deactivate_es_daily????????.dbf C:\QEns_Deacts /d " + lcDate
RUN &lcCommand 

I'm assuming XCOPY takes American date settings. I don't know if that is true in all locales, but you should be able to determine that with a little trial-and-error.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: XCOPY-DOS type function with VFP

But I still think it would be easier to use ADIR(). Plus that would also let you test for files modified between two dates.

Something like this:

CODE -->

lnCount = ADIR(laTemp, "R:\CDR\DES\deactivate_es_daily????????.dbf")
FOR lnI = 1 TO lnCount
  IF BETWEEN(laTemp(lnI, 3), periods.invoicedat+1, periods.pfrom)
    COPY FILE (laTemp(lnI, 1)) TO  C:\QEns_Deacts
  ENDIF 
ENDFOR 


Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: XCOPY-DOS type function with VFP

(OP)
OK, thank you all, Ive gone with the ADIR() to achieve it. :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close