In case there is anyone else out there looking for this solution, I actually came across an article that helped me remove any files. I know ChristNZ does not approve, but this is what works for what my company needs done. The macro below will now find all "ext" files in the "default" directory, delete any that are <70KB (this is because XML files are corrupt files if they are 68KB and clean but empty at 70KB), and finally convert any "ext" files to XLSX. I may be the only one to benefit from this, but now the information is out there. %macro convert_files(default=,ext=);
data _null_;
file "'&default\temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "If f.Size < 70000 And fso.GetExtensionName(f)=""&ext"" Then";
put " f.Delete True";
put " End If";
put " Next";
put " ";
put "for each f in myfiles";
put " ExtName = fso.GetExtensionName(f)";
put " Filename= fso.GetBaseName(f)";
put " if ExtName=""&ext"" then";
put " set mybook = xlapp.Workbooks.Open(f.Path)";
put " xlapp.Visible = false";
put " mybook.SaveAs ""&default.\"" & Filename & "".xlsx"", 51";
put " End If";
put " Next";
put " mybook.Close";
put " xlapp.DisplayAlerts = True";
/* Removes original files */
put " FSO.DeleteFile(""&default\*.&ext""), DeleteReadOnly";
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)";
run;
x "cscript ""&default\temp.vbs""";
%mend;
... View more