ciao a tutti
ho recuperato in retete il seguente codice per cancellare determinati file con determinata estensione in una determinata directory.
io avrei bisogno di escludere dei file (pippo.tmp,pluto.tmp,paperino.tmp)
ho pensato di farlo con un array ma essendo neofita non riesco.
qualcuno può aiutarmi????
IL CODICE :
codice:OPTION EXPLICIT on error resume next DIM strExtensionsToDelete,strFolder DIM objFSO ' ************************************************************ ' Setup ' ************************************************************ ' Folder to delete files from (files will also be deleted from subfolders) strFolder = "D:\" ' A comma separated list of file extensions ' Files with extensions provided in the list below will be deleted strExtensionsToDelete = "tmp" ' file da non cancellare ' ************************************************************ set objFSO = createobject("Scripting.FileSystemObject") RecursiveDeleteByExtension strFolder,strExtensionsToDelete sub RecursiveDeleteByExtension(byval strDirectory,strExtensionsToDelete) DIM objFolder, objSubFolder, objFile DIM strExt DIM skip(2) skip(0)="pippo" skip(1)="pluto" skip(2)="paperino" DIM count For count = 0 To UBound(skip) set objFolder = objFSO.GetFolder(strDirectory) for each objFile in objFolder.Files if instr(lcase(objFile.name),lcase(counter(skip))) = 0 then for each strExt in SPLIT(UCASE(strExtensionsToDelete),",") if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then objFile.Delete end if next else wscript.echo "File skippato: " & objFile.name end if next for each objSubFolder in objFolder.SubFolders RecursiveDeleteByExtension objSubFolder.Path,strExtensionsToDelete next end sub

Rispondi quotando

