BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASPhile
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

7 REPLIES 7
jdwaterman91
Obsidian | Level 7

Have you tried specifying the XMIN Option?

SASPhile
Quartz | Level 8

No ,havent tried

LinusH
Tourmaline | Level 20
Can't you use /s and omit the looping?
Data never sleeps
SASPhile
Quartz | Level 8

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

Reeza
Super User

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...

SASPhile
Quartz | Level 8
When the number of file sizes increases, I'm getting an error.
Xcopy.exe Application error popup.
Reeza
Super User

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. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 6491 views
  • 3 likes
  • 4 in conversation