1.

Solve : Copy folders in a batch?

Answer»

I am trying to use a bat to backup some folders but it won't copy the folders, only the loose files in the main folder.  How do I do this? 

I am also running into a problem with long names on some older files -- how do I tell the bat to skip that file and not stop the copying?what code are you using to copy the files at the moment?

you could try Code: [Select] xcopy /? to see if that would help.

do the longer file names have spaces in them?

FBI am using the xcopy.  Yes the names have spaces but this woman used to use very long names and it keeps telling me access denied.  I thought at FIRST it was because maybe the files were read only, but I checked and they aren't. 

When you say this woman, did she create the file your trying to copy... are they in her profile? That might be why your getting access denied.

alternatively are you running CMD as an administrator?

FBShe did create the document (word and excel) but there is no profile involved.  BASICALLY I am trying to back up her My Documents folder onto an external hard drive.  This folder contains a lot of folders that I can't make copy. 

I think the access denied is related to the fact that her file names a extremely long.  An example is "I had a discussion with George about new people walking by my office.doc" when I take a few of the spaces out then it copies without a hitch.  It does this on both excel and word docs. 

I don't know much about batch files that is why I am stumped, but I found this handy site and forum.  what version of windows are you running?

as long as you have quotation marks around the file names it shouldn't have a problem. i just copied a file called "whatever this file is called i'm going to change it.jpg" and it had no problem but i'm using vista.

If it works without the spaces we can build a workaround.

FBSo in the batch file I have to name the files?  I think that is a little more work than I want to do.   what version of windows are you running.

Do the files have any attributes.. hidden?

FB Quote

"I had a discussion with George about new people walking by my office.doc"

Xcopy will fail to copy a file if either the source or destination path and filename is, in total, more than 255 characters long.

That lady needs educating.


Sorry windows 2000 and yes I am working on getting her to shorten the names and not to use SYMBOLS (#$,&) she is getting there. 
Quote from: sukieb on August 23, 2008, 05:54:48 AM
I am working on getting her to shorten the names and not to use symbols (#$,&) she is getting there. 

Symbols are BAD NEWS especiall the &, known as the "poison character" because of its disruptive effect. This person needs to to go on a "Use of IT" course.



I figured it out!

I am not sure why this works but what I used is:

xcopy "c:\my documents\*" "h:\databackup\*" /m /e /y

That copies the folder and their contents plus only those files she has changed since the last backup.

My question is this -- will this take care of the error MESSAGE I get because of long file names?  I think it should since those will already be copied and won't change because they are old files. 


how does that only copy files that have been modified since the last backup?

/m copies files with archive attribute set.

/e copies files and directories, even empty ones.

and /y is default you don't need to add it.

if you want to copy files that have been changed since a certain date try  /d:m-d-y
which copies copies files that have been changed on or after the date m-d-y.

FB Quote from: sukieb on August 25, 2008, 10:09:42 AM

My question is this -- will this take care of the error message I get because of long file names?  I think it should since those will already be copied and won't change because they are old files. 

It's not just the file name length, but the total path length. They will not have been copied, and therefore the archive bit will still be set, and the message will RECUR.


Quote from: fireballs on August 25, 2008, 10:17:16 AM
how does that only copy files that have been modified since the last backup?

/m copies files with archive attribute set.


Read  the xcopy help again, fireballs.

  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.


Discussion

No Comment Found