From: ash007 on
Hello Sas-Users,

How can I move all the file .Txt and the file .Html in a directory
(without using the X command)? I am working on Window environment.

Thanks.

Ash007.
From: Kenneth M. Lin on

"ash007" <ramsamyashley(a)gmail.com> wrote in message
news:186c1b68-5283-44e9-a71c-f9f14fd93534(a)f33g2000vbm.googlegroups.com...
> Hello Sas-Users,
>
> How can I move all the file .Txt and the file .Html in a directory
> (without using the X command)? I am working on Window environment.
>
> Thanks.
>
> Ash007.

A better question is, why do you need to do this in SAS. If a tool wasn't
designed to perform certain tasks, why force it? You could easily move a
file from window explorer or better yet, put the files in the correct
location in the first place.

From: Paul Dorfman on
Ash,

OS is better (i.e. specifically) equipped to do that. However... few
things are impossible from within SAS. In your case, you can do, for
instance,

data _null_ ;
infile "old_dir\myfile.txt" lrecl=32767 ;
input ;
file "new_dir\myfile.txt" lrecl=32767 ;
put _infile_ ;
run ;

data _null_ ;
retain ff "dummy" ;
rc = filename (ff, "old_dir\myfile.txt") ;
rc = fdelete (ff) ;
put rc= ;
run ;

Ditto for .html. On a dinosaur note, I have a long-entrenched habit of
using a step similar to the first one above to copy (not too voluminous)
files under z/OS whenever I do not feel like adding another JCL step or
run IEBGENER, IDCAMS, IEBCOPY or another such utility from within SAS as
an external proc.

Kind regards
------------
Paul Dorfman
Jax, FL
------------

On Sun, 27 Sep 2009 03:37:57 -0700, ash007 <ramsamyashley(a)GMAIL.COM> wrote:

>Hello Sas-Users,
>
>How can I move all the file .Txt and the file .Html in a directory
>(without using the X command)? I am working on Window environment.
>
>Thanks.
>
>Ash007.
From: "Data _null_;" on
Use INFILE with PIPE access method to execute the COPY/MOVE command.

On 9/27/09, ash007 <ramsamyashley(a)gmail.com> wrote:
> Hello Sas-Users,
>
> How can I move all the file .Txt and the file .Html in a directory
> (without using the X command)? I am working on Window environment.
>
> Thanks.
>
> Ash007.
>
From: Randy Herbison on
This code will move all txt & html files from one folder to another:

%let oldFolder=c:\temp;
%let newFolder=c:\temp\test;

data _null_;
length filename $ 200;
* Assign FILEREF to old folder;
rc=filename('files2mv',"&oldFolder");
* Open old folder;
did=dopen('files2mv');
* Get # of files in folder;
memcount=dnum(did);
* Loop through folder looking for txt & html extensions;
do i=1 to memcount;
filename=dread(did,i);
if upcase(scan(filename,-1,'.')) in('HTML','TXT') then do;
* Move "txt" & "html" files to new folder;
rc=rename("&oldFolder\" || filename,"&newFolder\" || filename,'file');
end;
end;
* Close the folder;
did=dclose(did);
* Deassign FILEREF;
rc=filename('files2mv',' ');
run;


-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU] On Behalf Of ash007
Sent: Sunday, September 27, 2009 6:38 AM
To: SAS-L(a)LISTSERV.UGA.EDU
Subject: Move File with Sas pgm

Hello Sas-Users,

How can I move all the file .Txt and the file .Html in a directory
(without using the X command)? I am working on Window environment.

Thanks.

Ash007.
 |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Variable reduction method
Next: SUBSTR Madness