| Scripting.FileSystemObject, GetFolder, GetFile, Move |
|
|
| ' Verweis auf Microsoft Scripting Runtime muss gesetzt sein. |
| ' Übergeben werden der alte sowie der neue Verzeichnisname. |
|
| Function VerzeichnisNamen_aendern(AlterName, NeuerName) |
| Dim FileSyObj, OrdnerAlt |
| On Error GoTo KeinVerz |
|
| Set FileSyObj = CreateObject("Scripting.FileSystemObject") |
| Set OrdnerAlt = FileSyObj.GetFolder(AlterName) |
| OrdnerAlt.Move (NeuerName) |
| Set FileSyObj = Nothing |
| Set OrdnerAlt = Nothing |
|
| Exit Function |
| KeinVerz: |
| MsgBox "Quellverzeichnis ist falsch... ", vbExclamation, "Fehler" |
| End Function |
| |
|
| ' Dieses funktioniert sinngemäß mit GetFile für eine Änderung des Dateinamens: |
|
| Set FileSyObj = CreateObject("Scripting.FileSystemObject") |
| Set DateiX = FileSyObj.GetFile("C:\Programme\hallo.txt") |
| DateiX.Move ("C:\Programme\neuer_name.txt") |
| Set FileSyObj = Nothing |
| Set DateiX = Nothing |
|