Hi All, Is there any syntax without using X Copy to move files from 1 drive to another? Due to security reason IT security advised me not to use windows based command ( X copy). I have a new requirement now where in I have to transfer over 100 different formatted files (rtf,xls,txt,csv) in 1 go from 1 drive to another. I did google search and got this code, this code is creating copies in same folder by adding _new to the original file names. Not sure how to amend this code to dump all the files to in to another drive. let source=P:\Projects\Submissions\DEET18;
%macro directorylisting
( path = , outdsn = dirlist , where = , after = 01Jan1960 ) ;
data &outdsn. ( keep = filename fullfilename created modified bytes ) ;
attrib
dref length = $8
fref length = $8
folder length = $256
filename length = $128 label = 'Filename'
fullfilename length = $256 label = 'Full Filename'
created length = 8 label = 'Created' format = datetime19.
modified length = 8 label = 'Modified' format = datetime19.
bytes length = 8 label = 'Bytes' format = comma15. ;
if fileexist( "&path." ) then do ;
folder = ifc( substr( "&path.", lengthn( "&path." ), 1 ) = "\"
, "&path.", cats( "&path.", "\" ) ) ;
rc = filename( dref, folder );
did = dopen( dref ) ;
dcount = dnum( did ) ;
do i = 1 to dcount ;
filename = dread( did, i ) ;
if find( filename, "&where.", 'i' ) > 0 then do ;
fullfilename = cats( folder, filename ) ;
rc = filename( fref, fullfilename ) ;
fid = fopen( fref ) ;
modified = input( finfo( fid, 'Last Modified' ), anydtdtm. ) ;
if datepart( modified ) >= "&after."d then do ;
created = input( finfo( fid, 'Create Time' ), anydtdtm. ) ;
bytes = input( finfo( fid, 'File Size (bytes)' ), 18. ) ;
output ;
end ;
fid = fclose( fid ) ;
rc = filename( fref, '' ) ;
end ;
end ;
did = dclose( did ) ;
rc = filename( dref, '' ) ;
end ;
else put "ERROR: The folder &path. does not exist." ;
run ;
%mend ;
%directorylisting(path=&source);
%macro aa;
data _null_;
set dirlist;
pos1=index(filename,'.');
fname1="&source"||'\'||filename;
new_fname="&source"||'\'||substr(filename,1,pos1-1)||'_new'||substr(filename,pos1);
call symput('file'||strip(_n_), '"'||strip(fname1)||'"');
call symput('new_file'||strip(_n_),'"'||strip(new_fname)||'"');
call symput('cnt1',_n_);
run;
%do ii = 1 %to &cnt1;
%put &&file&ii=;
%put &&new_file&ii=;
/* these IN and OUT filerefs can point to anything */
filename in &&fileⅈ
filename out &&new_fileⅈ
/* copy the file byte-for-byte */
data _null_;
length filein 8 fileid 8;
filein = fopen('in','I',1,'B');
fileid = fopen('out','O',1,'B');
rec = '20'x;
do while(fread(filein)=0);
rc = fget(filein,rec,1);
rc = fput(fileid, rec);
rc =fwrite(fileid);
end;
rc = fclose(filein);
rc = fclose(fileid);
run;
filename in clear;
filename out clear;
%mend;
%mend aa;
%aa; Your help is much appreciated.
... View more