Date: Tue, 17 Sep 2002 11:20:48 -0700
Reply-To: "Miller, John" <millerj@WSIPP.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Miller, John" <millerj@WSIPP.WA.GOV>
Subject: Re: Win XP Filenames (OT)
Content-Type: text/plain
Chris,
This worked for me. Good luck.
options noxwait;
*-> Point at the directory you want to make changes in;
%let Directory = C:\Delme;
*-> Identify the character you wish to remove;
%let CharacterToRemove = -;
*-> Pipe in all of the files with the character embedded in the name;
filename myFiles pipe "dir &Directory\*&CharacterToRemove*.*";
data _null_;
infile myFiles;
input LineOfDir $ 80.;
*-> Output to a DOS batch file;
file "&Directory\FixNames.bat";
*-> If this is a line describing a file ...;
if substr(LineOfDir,3,1) eq "/" then
do;
*-> Get the name of the file;
ThisFileName = trim(substr(LineOfDir,40));
*-> Make a copy without the dash in the name;
FixedFileName = compress(ThisFileName,"&CharacterToRemove");
*-> Issue the command to rename the file;
RenameCommand = "Ren &Directory\" || trim(ThisFileName) || " " ||
trim(FixedFileName);
*-> Write out a rename statement for each file;
put RenameCommand;
end;
run;
*-> Submit the batch file;
x "&Directory\FixNames.bat"
-----Original Message-----
From: Chris [mailto:cyindra@AOL.COM]
Sent: Tuesday, September 17, 2002 10:06 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Win XP Filenames (OT)
Does anyone know a way of modifying all filenames in a directory. I
have around 400 files with dashes in the filename that I would like to
remove. Anyone try anything like this with %sysfunc.
TIA,
Chris