Page 1 of 1

Anyone have the correct syntax to remove a directory…?

Posted: Thu Nov 21, 2013 8:04 pm
by BuckXUK
Hello all



I'm trying to find the right syntax to remove a directory using the rmdir option in the Utility>Dir class. I've tried every possible syntax variation I can think of and cannot get this option to work.



This is the error I receive:



Error in line 76 of script : TypeError. 'rmdir' undefined or not a function



I've tried:



Dir.rmdir(variableName);



rmdir(variableName);



variableName.rmdir();



Dir.variableName.rmdir();



Can anyone point me in the right direction on this?



Thanks.



William Buckingham

Anyone have the correct syntax to remove a directory…?

Posted: Thu Nov 21, 2013 10:50 pm
by dkelly
Try



var theDir = new Dir(variableName);

theDir.rmdir();



or



var theDir = new Dir(variableName);

theDir.rmdirs();





The 2nd version will delete subdirectories (and files) if present.



Neither rmdir(dirName) and rmdirs(dirName) are NOT static members for some reason. I've reported the problem previously to Enfocus.

Anyone have the correct syntax to remove a directory…?

Posted: Fri Nov 22, 2013 3:34 am
by BuckXUK
Hi Dwight



Thanks for the response and I can report your 2nd option works.



I had declared the variableName in the exact same way as your syntax outside the if/else block that does the removal, but setting it inside the conditional block with your syntax sorted it out.



Thanks again.



William Buckingham



Anyone have the correct syntax to remove a directory…?

Posted: Fri Nov 22, 2013 3:27 pm
by dkelly
Buck, my guess why rmdir() didn't work is there was a file in the directory, possibly hidden.