Aleks
asked on
Copy files from one folder to another
Hi,
I saved a file as a .bat
the file has the code below. It simply copies the files inside a folder into another folder.
The problem is that it is not doing it, the black screen comes up and closes right away. I can only see it reads 'files copied 0', but can't see the error. The paths are correct. Both folders exist.
Any ideas?
I am running this on Windows 2012R2
I saved a file as a .bat
the file has the code below. It simply copies the files inside a folder into another folder.
xCopy /E/Y E:\source*.* E:\web\newfolder
The problem is that it is not doing it, the black screen comes up and closes right away. I can only see it reads 'files copied 0', but can't see the error. The paths are correct. Both folders exist.
Any ideas?
I am running this on Windows 2012R2
or did you mean to put:
to copy all files from folder "source"??
Beware also of long file names if the real name of "source" has spaces wrap the entire path in quotes
Another quick diagnostic is to simply open a CMD window and then paste your code in the command line, that way the window won't close.
xCopy E:\source\*.* E:\web\newfolder /E /Y
to copy all files from folder "source"??
Beware also of long file names if the real name of "source" has spaces wrap the entire path in quotes
xCopy "E:\my long path name\*.*" "E:\web\my other long path name" /E /Y
Another quick diagnostic is to simply open a CMD window and then paste your code in the command line, that way the window won't close.
proper syntax.. robocopy source destination options
> proper syntax.. robocopy source destination options
He's using xcopy, not robocopy.
xcopy /? will show its proper syntax.
He's using xcopy, not robocopy.
xcopy /? will show its proper syntax.
ASKER
I meant files
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You must run the batch script at an elevated admin level - RIGHT-click on the batch file, select "Run as Administrator".
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Doesn't need admin. That didn't work. I'll try again tonight. The script seems to run fine in a different server
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I was away for a few days. I will add the pause command tonight and post the results
Sounds good.
ASKER
I checked and no errors, the problem is that its only copying one file, no folders or anything like that.
It copies one ASP, the rest are not copied over.
xCopy /E/Y E:\source\ASPS*.* E:\web\
It copies one ASP, the rest are not copied over.
ASKER
Strange, in fact it takes the folder ASPS and copies it over to the target /web/ folder adds the ASPS and some of the files there, not all.
ASKER
Found the issue, it was missing a \
xCopy /E/Y E:\source\ASPS\*.*
xCopy /E/Y E:\source\ASPS\*.*
ASKER
Thanks for the follow up
> problem is that its only copying one file, no folders or anything like that.
You're doing the same thing as I mentioned earlier. Please read my post #a42152923. ASPS*.* is a wildcard for files. Now read my post #a42153002, which shows that you probably want this:
E:\source\ASPS\*.*
Regards, Joe
You're doing the same thing as I mentioned earlier. Please read my post #a42152923. ASPS*.* is a wildcard for files. Now read my post #a42153002, which shows that you probably want this:
E:\source\ASPS\*.*
Regards, Joe
When I hit Submit, I see that our messages crossed. Very glad to see that you figured it out! Regards, Joe
ASKER
Ha! .. Thanks Joe :)
Place a pause command in the batch file after the xcopy command and it will keep the window from closing so you'll be able to see the error message (which is probably going to be "Cannot perform a cyclic copy").
> Both folders exist.
source*.* is not a folder — it is a wildcard for files. Perhaps you meant this:
Open in new window
Regards, Joe