Or If you like batch file.
Assuming all the files are in c:\temp directory.
[pre]
filename fname pipe 'dir c:\temp\*.* /b';
data _null_;
file 'c:\rename.bat';
infile fname length=len;
input name $varying100. len;
if (length(scan(name,1,'.')) gt 😎 then do;
if findc(strip(name),' ') then do;
rename='rename '||strip(scan(name,1,' .'))||'*.'||strip(scan(name,-1,'.'))||
' '||strip(substr(compress(name),1,6))||'~1.'||strip(scan(name,-1,'.'));
put rename;
end;
else if findc(strip(name),'.') then do;
rename='rename '||strip(name)||' '||
strip(substr(compress(name),1,6))||'~1.'||strip(scan(name,-1,'.'));
put rename;
end;
else do;
rename='rename '||strip(name)||' '||strip(substr(compress(name),1,6))||'~1';
put rename;
end;
end;
run;
x "cd c:\temp\";
x "c:\rename.bat";
x "del c:\rename.bat";
run;
[/pre]
Ksharp
... View more