Xcopy

Accepted Solution Solved
Reply
Super Contributor
Posts: 673
Accepted Solution

Xcopy

I have to copy 14K files from one directory to another. when using the below code, the cmd window opens 14K times and this is interrupting from doing further work. 

1. How to make it work with out interrupting the user?

2. If the files are already presnt in destination folder, either delete them or overwrite them. The following code popups cmd window to manually key in the response by the user.

How to achieve above two conditions?

 

options noxwait noxsync;
data _null_;
%do i=1 %to &count.;
%sysExec xcopy "&landing_zone.\&&memname&i" "&dest.\";
%end;
run;
proc printto;
run;


Accepted Solutions
Solution
‎06-15-2017 01:35 PM
Super User
Posts: 19,090

Re: Xcopy

You're passing a system command and need to find the relevant system option. 

 

For XCOPY that appears to be /Y

 

See the Microsoft documentation, here:

https://support.microsoft.com/en-us/help/240268/copy,-xcopy,-and-move-overwrite-functionality-change...

View solution in original post


All Replies
Contributor
Posts: 22

Re: Xcopy

Have you tried specifying the XMIN Option?

Super Contributor
Posts: 673

Re: Xcopy

No ,havent tried

Super User
Posts: 5,383

Re: Xcopy

Can't you use /s and omit the looping?
Data never sleeps
Super Contributor
Posts: 673

Re: Xcopy

never tried that.

Looping lets me choose only the files of interest. I'm not sure how /s works.

 

if there are

abc.txt

pqr.txt

xyz.txt

and I want to choose only pqr.txt and xyz.txt based on some conditions, I will pass the two file names into a macro array and loop them to move to a new folder.

Imagine i had to move 14k files out of 50k

Solution
‎06-15-2017 01:35 PM
Super User
Posts: 19,090

Re: Xcopy

You're passing a system command and need to find the relevant system option. 

 

For XCOPY that appears to be /Y

 

See the Microsoft documentation, here:

https://support.microsoft.com/en-us/help/240268/copy,-xcopy,-and-move-overwrite-functionality-change...

Super Contributor
Posts: 673

Re: Xcopy

When the number of file sizes increases, I'm getting an error.
Xcopy.exe Application error popup.
Super User
Posts: 19,090

Re: Xcopy

Like I mentioned you're using Windows command, SAS is just passing it to the system. Figure out what works in the system and that's a Windows question, not a SAS question. 

 

Then incorporate that solution here. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 371 views
  • 2 likes
  • 4 in conversation