• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Copying just files in directories with the archive attrribute set

I used to back up new files on my harddisk drives to my network drive using the dos command:

copy c:\ed\*.* n:\edbackup\ /s /m /i /d:10/10/2002

that is: copy everything in c:\ed\ directory to n:\edbackup\ ; inlcude subdiretories;, if a new or modified file [archive attribute will have been set]then copy this file over, but switch off the archive attribute in the original ; assume if destination does not exist that destination is a directory; copy everything created or modified since date of last big backup.

This no longer works on my windows 2000 system, and i'm trying to produce a more flexible system in Delphi.  I have an efficient file copy procedure thanks to expertsXexchange based on the ShellAPI:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20330170.html

But don't know how to just copy those files with thearchive attribute set (and to turn it off of the files I've copied). Is there an easy (and efficient) way to do this,or do I have to do it the long way (open each relevant file, copy line by line, close, etc)??

help much appreciated,

Daz


0
dvanlaar
Asked:
dvanlaar
1 Solution
 
PeterLarsenCommented:
Hi Daz,

Hope this will help :

procedure TForm1.Button1Click(Sender: TObject);
var
 SR: TSearchRec;
begin
 if FindFirst(IncludeTrailingBackslash(ExtractFilePath(Application.ExeName))+'*.*', $00000020, SR) = 0 then
 begin
  repeat

   {Do your copy stuff here with CopyFile or save the
    names in a list for later use with SHFileOperation}

  until FindNext(SR) <> 0;
  FindClose(SR);
 end; //end if
end;


Peter
0
 
KCBrecksCommented:
If you want to alter the attribitres for a file then the FileSetAttr() function is available in the SysUtils unit. Look in the Help system for File Attributes

Unit

Sysutils

Category

file management routines

function FileSetAttr(const FileName: string; Attr: Integer): Integer;

Description

FileSetAttr sets the file attributes of the file given by FileName to the value given by Attr. The value of Attr is formed by combining the appropriate file attribute constants, as in the following:

FileSetAttr('MyFile.sys', faReadOnly or faSysFile);

FileSetAttr returns zero if the function was successful. Otherwise the return value is a Windows error code.

Note:     See TSearchRec for a description of the file attribute constants.

This is a straight copy of the Delphi Help file.

Keith

0
 
dvanlaarAuthor Commented:
Thanks so far,

Finding and setting the attributes on the individual files and then copying them individually is not the problem. I would like to only copy particular files within a *very* large directory structure using a quick and efficient copy procedure such as ShellAPI FO_COPY or similar.  

Is there anyway of checking the attributes of the files as they are being copied over,or only letting the ShellAPI copy procedure 'see' files with a particular attribute?

I know this can be done as it appears to be implemented in the Dos copy, xcopy or xcopy32 commands.

Daz

 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
dvanlaarAuthor Commented:
Thanks so far,

Finding and setting the attributes on the individual files and then copying them individually is not the problem. I would like to only copy particular files within a *very* large directory structure using a quick and efficient copy procedure such as ShellAPI FO_COPY or similar.  

Is there anyway of checking the attributes of the files as they are being copied over,or only letting the ShellAPI copy procedure 'see' files with a particular attribute?

I know this can be done as it appears to be implemented in the Dos copy, xcopy or xcopy32 commands.

Daz

 
0
 
PeterLarsenCommented:
It's better to use FindFirst (or similar function) to find the  files because you may choose to continue - or whatever you want to do - even if a file-copy fails.

>> "But don't know how to just copy those files with thearchive attribute set.."
FindFirst/FindNext only find the files who match the Attr parameter.
0
 
CleanupPingCommented:
dvanlaar:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
snehanshuCommented:
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: PeterLarsen

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now