09-16-2022, 01:07 PM (This post was last modified: 09-16-2022, 01:07 PM by SpriggsySpriggs.)
It threw me off when I was reading your code with all those dots in the variable names. I thought you left off some TYPE definition at first. Cool code.
I like using dots but mostly just when I use TYPEs, for the same reason.
So if I had
LINE INPUT "Make what Dir/Path: "
And input "myfolder\folder1\pete"
I would get a$ = "myfolder\folder1\pete"
Parse it out with INSTR()
myfolder
folder1
pete
Check for IF _DIREXISTS for each parsed dir name.
Make the directory if it does not exists.
Follow the parsing down the path to completion.
That's handy.
Does it also get into making multiple sub-directories like: myfolder/folder1, myfolder/folder2, etc.? I used to use a FOR/NEXT loop to assign sub-folders numbers with a MKDIR loop for that.
And for me, unless I was needing to really create these directories all the time I'd just use PowerShell to do it once. You're probably not going to be making directories that often where the speed will be something critical. Usually, I make a program that checks for something existing and if it doesn't, it makes it. And if I was only needing it for that first launch, I'd just use PowerShell. Less code needed and you can still find out if it succeeded or not.
09-17-2022, 02:03 AM (This post was last modified: 09-19-2022, 02:44 AM by eoredson.)
(09-16-2022, 03:18 PM)Pete Wrote: I like using dots but mostly just when I use TYPEs, for the same reason.
Does it also get into making multiple sub-directories like: myfolder/folder1, myfolder/folder2, etc.? I used to use a FOR/NEXT loop to assign sub-folders numbers with a MKDIR loop for that.
Pete
@pete: Yes! I could easily add multiple paths on input. For example:
09-17-2022, 11:43 AM (This post was last modified: 09-17-2022, 11:43 AM by Kernelpanic.)
This is probably easier to do with VBScript (Windows Scripting Host).
The program example should show that you can also delete under Windows without asking. I have now changed it so that a folder is created via the query, which is then automatically after 5 seconds deleted again. That could certainly be easily converted to create any folder. In the end it's more of a gimmick. But one can learn from it.
In my example, the folder "Beispiel" is created in H:\Ablage\Beispiel. Adapt it to your own system when trying it out. Name: XYZ.vbs
Code: (Select All)
'Windows Scripting Host Beispiel, 15. April 2019/14. Sept. 2022
'Erstellt einen Ordner und löscht ihn nach 5 sek. ohne Abfrage
'Variablendeklaration erzwingen
Option Explicit
Dim Pfad, NeuerPfad, OrdnerAnzeigen
Dim fso, fo
NeuerPfad = Inputbox("Neuen Ordner mit Pfad angeben: ")
'Hier: H:\Ablage\Beispiel
Pfad = NeuerPfad
'FileSystemObject erzeugen fuer Zugriff
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'Pruefen ob Ordner schon existiert
If (Not fso.FolderExists(Pfad)) Then
'Ordner erstellen
Set fo = fso.CreateFolder(Pfad)
End If