Disclaimer, im nowhere near a programmer. More for the hobby, to learn and to make my work easier.
For work I have a programm that changes some text in a Gcode file. Simple things like changing the rpm’s for certain movements. Now Im moving certain files if they contain G119
. If all files are moved, the original folder is empty and i want to delete it.
This is what I tried:
Function DeleteEmptyFolder(strFile)
Dim fs, ts, contents, MainFolder, ParentFolder, BrugFolder
set fs = CreateObject("Scripting.FileSystemObject")
MainFolder = fs.GetParentFolderName(strFile)
ParentFolder = fs.GetParentFolderName(MainFolder)
BrugFolder = MainFolder & "_Brug"
if (MainFolder.files.count = 0) then
wscript.echo "works till here"
End if
End function
Where strFile
is strFile = (file.path)
.
The error i get is Object required: 'MainFolder'
So I tried to change it to Function DeleteEmptyFolder(ByRef strFile)
. Just to try it.
I also tried if (fs.GetParentFolderName(strFile).files.count = 0) then
to see if it acts as an object then but it doesnt.
So can I “convert” a string into an object? or give an object on to a Fuction?
Or is this just not the way and do i have to achieve this in a whole different way?
ps. I could paste the lines into the original program instead of having a seperate function, but I try to learn about VBS. So i thought maybe there actually is a way to do this.