• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

Script to find empty directories

This script finds empty directories and displays them using the wscript.echo method. But I want it to dump the finds into a csv file. How can I go about doing this? Thanks  
On Error Resume Next

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("\\wn2790\S$")

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
    If Subfolder.Size = 0 Then
        Wscript.Echo Subfolder.Path
    End If
        ShowSubFolders Subfolder
    Next
End Sub

Open in new window

0
kulisncc
Asked:
kulisncc
  • 5
  • 2
2 Solutions
 
honestman31Commented:
try this and let me know
On Error Resume Next

Set FSO = CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("c:\out.csv", True)
ShowSubfolders FSO.GetFolder("\\wn2790\S$")

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
    If Subfolder.Size = 0 Then
        Wscript.Echo Subfolder.Path
	OutPutFile.Write "," & "folder: " & Subfolder.Path
    End If
        ShowSubFolders Subfolder
    Next
End Sub

Open in new window

0
 
Bill PrewCommented:
Just to make sure you know, you could use your existing script, and just redirect the output to a CSV file when you run it (either from a command line, or a BAT file), by doing:

cscript //nologo yourscript.vbs > output.csv

~bp
0
 
kulisnccAuthor Commented:
I will let you both know and billprew that is great, I didnt even think of that. I will try it in the morning when I get to work and let you both know. Thanks for your help.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kulisnccAuthor Commented:
Okay, I ran the script above honestman31 but nothing happened and then I redirected like billprew had suggested and it worked great. What I would really like for this script to also do is to create a directory named after the computername of the system it will be ran on. I can create a batch file to do this but it would be nice to have it all done in one script. Thanks
0
 
kulisnccAuthor Commented:
Okay, whew. I worked on a batch script for a few days trying to accomplish what I wanted. I am not Ed Wilson so I dont have the best vbs skills out there which is why I created the following batch script to call on the vbs script I got from the Hey Scripting Guy blog off of Microsoft. There are actually multiple scripts at play. Here is a list of the scripts I have created to do what I want:

1. call_find_empty_dirs_vbs.bat
2. find_empty_dirs.vbs
3. del_file.bat

I created multiple vbs scripts in a directory called "call_vbs_folder" and you can see this listed under the "Setting cscript variables" commented section. What I did here was simply created the same "find_empty_dirs.vbs" script but added the admin share at the end of the filename like "find_empty_dirs_c$.vbs" and so on and so forth all the way up to z$. I did this so the batch file will call upon the vbs that relates to the admin share of course. So, really there are more than just 3 scripts but the code is the same for the vbs just the filenames are different like I stated. The code for the main batch file that calls on the vbs is listed first, the vbs second and the "del_file.bat" third. I created the "del_file.bat" because if you would prefer running the batch file from your desktop you can and then this batch file simply deletes it afterward so as not to clutter your desktop.

I worked my ass off on this by the way so go easy on the comments regarding how superfluous and idiotic this is. I love constructive criticism though. Thanks everyone.
Copy this code and save it in a text file and change the name to del_file.bat
-----------------------------------------------------------------

@echo off

if exist "%userprofile%\desktop\call_find_empty_dirs_vbs.bat"

del "%userprofile%\desktop\call_find_empty_dirs_vbs.bat"

exit

Open in new window

Copy and paste the code below in a text file and save it as "call_find_empty_dirs_vbs.bat"
-----------------------------------------------------------------

@echo off

::---------------------------------------------------------------------------------------------------------------------------
:: 	Created by: <your name here>
::	
::	Date: 
::	
::	Explanation of script function:
::	
::	This script searches for empty directories on any system specified in the "computername" variable and exports the location of these empty directories as UNC paths to a csv file within its respective admin share (D$, E$ etc).  
::---------------------------------------------------------------------------------------------------------------------------

::---------------------------------------------------------------------------------------------------------------------------
	Echo Step 1 - Prompt for setting the computername input variable 
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	You can change the computername input variable below to equal the name of any system needing to be scanned when prompted.
::===========================================================================================================================

:input

set input=
set /P input=Enter computer name: %=%
 
if "%input%"=="" goto input

Echo Your computer selection is: %input%

@pause

set computername=%INPUT%

::---------------------------------------------------------------------------------------------------------------------------
	Echo Step 2 - Setting variables
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	Setting admin share variables
::===========================================================================================================================

set cshare=\\%computername%\c$
set dshare=\\%computername%\d$
set eshare=\\%computername%\e$
set fshare=\\%computername%\f$
set gshare=\\%computername%\g$
set hshare=\\%computername%\h$
set ishare=\\%computername%\i$
set jshare=\\%computername%\j$
set kshare=\\%computername%\k$
set lshare=\\%computername%\l$
set mshare=\\%computername%\m$
set nshare=\\%computername%\n$
set oshare=\\%computername%\o$
set pshare=\\%computername%\p$
set qshare=\\%computername%\q$
set rshare=\\%computername%\r$
set sshare=\\%computername%\s$
set tshare=\\%computername%\t$
set ushare=\\%computername%\u$
set vshare=\\%computername%\v$
set wshare=\\%computername%\w$
set xshare=\\%computername%\x$
set yshare=\\%computername%\y$
set zshare=\\%computername%\z$

::===========================================================================================================================
::	Setting the path variables
::
::	varpath1 will be the variable that holds the value of the UNC path to where this batch script and vbs script file is located for example: \\computername\scripts_directory\find_empty_dirs\
::	varpath2 will be the variable that holds the value of the UNC path to where the directory is named after the scanned system that contains the directories of the admin shares containing the csv files. This will need the %computername% environmental variable in the path, for example: \\computername\scripts_directory\find_empty_dirs\scanned_systems\%computername%\
::	varpath3 will be the variable that holds the value of the UNC path to where the directory is containing all the scanned systems, for example: \\computername\scripts_directory\find_empty_dirs\scanned_systems\
::===========================================================================================================================

set varpath1=\\computername\scripts_directory\find_empty_dirs\
set varpath2=\\computername\scripts_directory\find_empty_dirs\scanned_systems\%computername%\
set varpath3=\\computername\scripts_directory\find_empty_dirs\scanned_systems\

::===========================================================================================================================
::	Setting UNC path variables
::===========================================================================================================================

set csharedir=%varpath2%C$
set dsharedir=%varpath2%D$
set esharedir=%varpath2%E$
set fsharedir=%varpath2%F$
set gsharedir=%varpath2%G$
set hsharedir=%varpath2%H$
set isharedir=%varpath2%I$
set jsharedir=%varpath2%J$
set ksharedir=%varpath2%K$
set lsharedir=%varpath2%L$
set msharedir=%varpath2%M$
set nsharedir=%varpath2%N$
set osharedir=%varpath2%O$
set psharedir=%varpath2%P$
set qsharedir=%varpath2%Q$
set rsharedir=%varpath2%R$
set ssharedir=%varpath2%S$
set tsharedir=%varpath2%T$
set usharedir=%varpath2%U$
set vsharedir=%varpath2%V$
set wsharedir=%varpath2%w$
set xsharedir=%varpath2%x$
set ysharedir=%varpath2%Y$
set zsharedir=%varpath2%Z$

::===========================================================================================================================
::	Using For loop to assign date stamp to csv filenames
::===========================================================================================================================

@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( 
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%%A-%%B-%%C
)

::===========================================================================================================================
::	Setting cscript variables
::===========================================================================================================================

set callvbsc$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_c$.vbs
set callvbsd$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_d$.vbs
set callvbse$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_e$.vbs
set callvbsf$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_f$.vbs
set callvbsg$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_g$.vbs
set callvbsh$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_h$.vbs
set callvbsi$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_i$.vbs
set callvbsj$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_j$.vbs
set callvbsk$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_k$.vbs
set callvbsl$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_l$.vbs
set callvbsm$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_m$.vbs
set callvbsn$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_n$.vbs
set callvbso$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_o$.vbs
set callvbsp$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_p$.vbs
set callvbsq$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_q$.vbs
set callvbsr$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_r$.vbs
set callvbss$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_s$.vbs
set callvbst$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_t$.vbs
set callvbsu$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_u$.vbs
set callvbsv$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_v$.vbs
set callvbsw$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_w$.vbs
set callvbsx$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_x$.vbs
set callvbsy$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_y$.vbs
set callvbsz$=cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir_z$.vbs

::---------------------------------------------------------------------------------------------------------------------------
	Echo Steps 3 and 4 - Checks for existence of admin shares and if exist, create admin share directories. Checks if admin share directories exist, if exist, run vbs script to create csv files with a date stamped filename.
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	Step 3 - Checks for existence of admin shares and if exist, create admin share directories.
::===========================================================================================================================

IF EXIST %varpath2% (
        goto nextc$
    ) ELSE (
        md %varpath2%
    ) 

goto nextc$

:nextc$
IF EXIST %cshare% (
	md %csharedir%
    ) ELSE (
	goto nextd$
    )

goto nextd$
	
:nextd$
IF EXIST %dshare% (
	md %dsharedir%
    ) ELSE (
	goto nexte$ 
    )

goto nexte$

:nexte$
IF EXIST %eshare% (
	md %esharedir%
    ) ELSE (
	goto nextf$ 
    )

goto nextf$

:nextf$
IF EXIST %fshare% (
	md %fsharedir%
    ) ELSE (
	goto nextg$ 
    )

goto nextg$

:nextg$
IF EXIST %gshare% (
	md %gsharedir%
    ) ELSE (
	goto nexth$ 
    )

goto nexth$

:nexth$
IF EXIST %hshare% (
	md %hsharedir%
    ) ELSE (
	goto nexti$ 
    )

goto nexti$

:nexti$
IF EXIST %ishare% (
	md %isharedir%
    ) ELSE (
	goto nextj$ 
    )

goto nextj$

:nextj$
IF EXIST %jshare% (
	md %jsharedir%
    ) ELSE (
	goto nextk$ 
    )

goto nextk$

:nextk$
IF EXIST %kshare% (
	md %ksharedir%
    ) ELSE (
	goto nextl$ 
    )

goto nextl$

:nextl$
IF EXIST %lshare% (
	md %lsharedir%
    ) ELSE (
	goto nextm$ 
    )

goto nextm$

:nextm$
IF EXIST %mshare% (
	md %msharedir%
    ) ELSE (
	goto nextn$ 
    )

goto nextn$

:nextn$
IF EXIST %nshare% (
	md %nsharedir%
    ) ELSE (
	goto nexto$ 
    )

goto nexto$

:nexto$
IF EXIST %oshare% (
	md %osharedir%
    ) ELSE (
	goto nextp$ 
    )

goto nextp$

:nextp$
IF EXIST %pshare% (
	md %psharedir%
    ) ELSE (
	goto nextq$ 
    )

goto nextq$

:nextq$
IF EXIST %qshare% (
	md %qsharedir%
    ) ELSE (
	goto nextr$ 
    )

goto nextr$

:nextr$
IF EXIST %rshare% (
	md %rsharedir%
    ) ELSE (
	goto nexts$ 
    )

goto nexts$

:nexts$
IF EXIST %sshare% (
	md %ssharedir%
    ) ELSE (
	goto nextt$ 
    )

goto nextt$

:nextt$
IF EXIST %tshare% (
	md %tsharedir%
    ) ELSE (
	goto nextu$ 
    )

goto nextu$

:nextu$
IF EXIST %ushare% (
	md %usharedir%
    ) ELSE (
	goto nextv$ 
    )

goto nextv$

:nextv$
IF EXIST %vshare% (
	md %vsharedir%
    ) ELSE (
	goto nextw$ 
    )

goto nextw$

:nextw$
IF EXIST %wshare% (
	md %wsharedir%
    ) ELSE (
	goto nextx$ 
    )

goto nextx$

:nextx$
IF EXIST %xshare% (
	md %xsharedir%
    ) ELSE (
	goto nexty$ 
    )

goto nexty$

:nexty$
IF EXIST %yshare% (
	md %ysharedir%
    ) ELSE (
	goto nextz$ 
    )

goto nextz$

:nextz$
IF EXIST %zshare% (
	md %zsharedir%
    ) ELSE (
	goto csharedir
    )

goto csharedir

::===========================================================================================================================
::	Step 4 - Checks if admin share directories exist, if exist, run vbs script to create csv files with a date stamped filename.
::===========================================================================================================================

:csharedir
IF EXIST %csharedir% (
	%callvbsc$% > %csharedir%\%All%.csv 
    ) ELSE (
	goto dsharedir
    )

goto dsharedir

:dsharedir
IF EXIST %dsharedir% (
	%callvbsd$% > %dsharedir%\%All%.csv 
    ) ELSE (
	goto esharedir
    )

goto esharedir

:esharedir
IF EXIST %esharedir% (
	%callvbse$% > %esharedir%\%All%.csv 
    ) ELSE (
	goto fsharedir
    )

goto fsharedir

:fsharedir
IF EXIST %fsharedir% (
	%callvbsf$% > %fsharedir%\%All%.csv 
    ) ELSE (
	goto :gsharedir
    )

goto gsharedir

:gsharedir
IF EXIST %gsharedir% (
	%callvbsg$% > %gsharedir%\%All%.csv 
    ) ELSE (
	goto hsharedir
    )

goto hsharedir

:hsharedir
IF EXIST %hsharedir% (
	%callvbsh$% > %hsharedir%\%All%.csv 
    ) ELSE (
	goto isharedir
    )

goto isharedir

:isharedir
IF EXIST %isharedir% (
	%callvbsi$% > %isharedir%\%All%.csv 
    ) ELSE (
	goto jsharedir
    )

goto jsharedir

:jsharedir
IF EXIST %jsharedir% (
	%callvbsj$% > %jsharedir%\%All%.csv 
    ) ELSE (
	goto ksharedir
    )

goto ksharedir

:ksharedir
IF EXIST %ksharedir% (
	%callvbsk$% > %ksharedir%\%All%.csv 
    ) ELSE (
	goto lsharedir
    )

goto lsharedir

:lsharedir
IF EXIST %lsharedir% (
	%callvbsl$% > %lsharedir%\%All%.csv 
    ) ELSE (
	goto msharedir
    )

goto msharedir

:msharedir
IF EXIST %msharedir% (
	%callvbsm$% > %msharedir%\%All%.csv 
    ) ELSE (
	goto nsharedir
    )

goto nsharedir

:nsharedir
IF EXIST %nsharedir% (
	%callvbsn$% > %nsharedir%\%All%.csv 
    ) ELSE (
	goto osharedir
    )

goto osharedir

:osharedir
IF EXIST %osharedir% (
	%callvbso$% > %osharedir%\%All%.csv 
    ) ELSE (
	goto psharedir
    )

goto psharedir

:psharedir
IF EXIST %psharedir% (
	%callvbsp$% > %psharedir%\%All%.csv 
    ) ELSE (
	goto qsharedir
    )

goto qsharedir

:qsharedir
IF EXIST %qsharedir% (
	%callvbsq$% > %qsharedir%\%All%.csv 
    ) ELSE (
	goto rsharedir
    )

goto rsharedir

:rsharedir
IF EXIST %rsharedir% (
	%callvbsr$% > %rsharedir%\%All%.csv 
    ) ELSE (
	goto ssharedir
    )

goto ssharedir

:ssharedir
IF EXIST %ssharedir% (
	%callvbss$% > %ssharedir%\%All%.csv 
    ) ELSE (
	goto tsharedir
    )

goto tsharedir

:tsharedir
IF EXIST %tsharedir% (
	%callvbst$% > %tsharedir%\%All%.csv 
    ) ELSE (
	goto usharedir
    )

goto usharedir

:usharedir
IF EXIST %usharedir% (
	%callvbsu$% > %usharedir%\%All%.csv 
    ) ELSE (
	goto vsharedir
    )

goto vsharedir

:vsharedir
IF EXIST %vsharedir% (
	%callvbsv$% > %vsharedir%\%All%.csv 
    ) ELSE (
	goto wsharedir
    )

goto wsharedir

:wsharedir
IF EXIST %wsharedir% (
	%callvbsw$% > %wsharedir%\%All%.csv 
    ) ELSE (
	goto xsharedir
    )

goto xsharedir

:xsharedir
IF EXIST %xsharedir% (
	%callvbsx$% > %xsharedir%\%All%.csv 
    ) ELSE (
	goto ysharedir
    )

goto ysharedir

:ysharedir
IF EXIST %ysharedir% (
	%callvbsy$% > %ysharedir%\%All%.csv 
    ) ELSE (
	goto zsharedir
    )

goto zsharedir

:zsharedir
IF EXIST %zsharedir% (
	%callvbsz$% > %zsharedir%\%All%.csv 
    ) ELSE (
	goto scanagain
    )

goto scanagain


::===========================================================================================================================
::	Step 5 - Prompt asking if you would like to perform a scan on another system
::===========================================================================================================================

:scanagain

SET /P ANSWER=Would you like to perform another scan (Y/N)?

Echo You chose: %ANSWER%

if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)

goto :no

:yes
Echo You pressed Yes!
@pause
goto input

:no
Echo You pressed No! Goodbye and have a great day
@pause
goto explorer

::===========================================================================================================================
::	Step 6 - Opening the Scanned_Systems directory
::===========================================================================================================================

:explorer

explorer %varpath3%

goto delfile

::===========================================================================================================================
::	Step 7 - Deleting batch file from desktop if exist
::===========================================================================================================================

:delfile

%varpath1%del_file.bat

Open in new window

Below is the code for the find_empty_dirs.vbs script. Remember to create multiple vbs files containing this code for each admin share (drive) on the remote system and change the ShowSubfolders FSO.GetFolder variable for each admin share. So for instance, save the code below and save it as a text file and change the file extension to vbs. Then change the ShowSubfolders FSO.GetFolder("\\computername\C$") to a D$ and then save that as a vbs file with the filename being "find_empty_dirs_d$.vbs" and so on all the way up to Z$. I know this is alot of work. 
-----------------------------------------------------------------

On Error Resume Next

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("\\computername\C$")

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
    If Subfolder.Size = 0 Then
        Wscript.Echo Subfolder.Path
    End If
        ShowSubFolders Subfolder
    Next
End Sub

Open in new window

0
 
kulisnccAuthor Commented:
Oops, the del_file.bat is listed first, then the call_find_empty_dirs_vbs.bat, then the find_empty_dirs.vbs. Let me know what you all think. Thanks.
0
 
Bill PrewCommented:
Just a thought on a slightly more compact approach. We can pass the folder to scan to the VBS script, so no need to have more than one of those. In addition, we can use some looping in the BAT script to reduce the lines of code. See what you think.

@echo off
setlocal EnableDelayedExpansion

::---------------------------------------------------------------------------------------------------------------------------
:: 	Created by: <your name here>
::	
::	Date: 
::	
::	Explanation of script function:
::	
::	This script searches for empty directories on any system specified in the "computername" variable and exports the location of these empty directories as UNC paths to a csv file within its respective admin share (D$, E$ etc).  
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	Using For loop to assign date stamp to csv filenames
::===========================================================================================================================

@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( 
  Set Day=%%A
  Set Month=%%B
  Set Year=%%C
  Set All=%%A-%%B-%%C
)

::===========================================================================================================================
::	Define list of drive letters we will scan
::===========================================================================================================================

set Drives=c$,d$,e$,f$,g$,h$,i$,j$,k$,l$,m$,n$,o$,p$,q$,r$,s$,t$,u$,v$,w$,x$,y$,z$

::---------------------------------------------------------------------------------------------------------------------------
::  Echo Step 1 - Prompt for setting the computername input variable 
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	You can change the computername input variable below to equal the name of any system needing to be scanned when prompted.
::===========================================================================================================================

:input

set input=
set /P input=Enter computer name: %=%
 
if "%input%"=="" goto input

Echo Your computer selection is: %input%

@pause

set computername=%INPUT%

::---------------------------------------------------------------------------------------------------------------------------
	Echo Step 2 - Setting variables
::---------------------------------------------------------------------------------------------------------------------------

::===========================================================================================================================
::	Setting the path variables
::
::	varpath1 will be the variable that holds the value of the UNC path to where this batch script and vbs script file is located for example: \\computername\scripts_directory\find_empty_dirs\
::	varpath2 will be the variable that holds the value of the UNC path to where the directory is named after the scanned system that contains the directories of the admin shares containing the csv files. This will need the %computername% environmental variable in the path, for example: \\computername\scripts_directory\find_empty_dirs\scanned_systems\%computername%\
::	varpath3 will be the variable that holds the value of the UNC path to where the directory is containing all the scanned systems, for example: \\computername\scripts_directory\find_empty_dirs\scanned_systems\
::===========================================================================================================================

set varpath1=\\computername\scripts_directory\find_empty_dirs\
set varpath2=\\computername\scripts_directory\find_empty_dirs\scanned_systems\%computername%\
set varpath3=\\computername\scripts_directory\find_empty_dirs\scanned_systems\

IF NOT EXIST "%varpath2%" md "%varpath2%"

::===========================================================================================================================
::	Loop through all possible drive letters to check on this server
::===========================================================================================================================

FOR %%A in (%Drives%) DO (
  set share=\\%computername%\%%A
  set sharedir=%varpath2%%%A
  IF EXIST "!share!" (
    IF NOT EXIST "!sharedir!" md "!sharedir!"
    cscript //nologo %varpath1%Call_VBS_Folder\Find_empty_dir.vbs "!schare!" > "!sharedir!\%All%.csv"
  )
)

::===========================================================================================================================
::	Step 5 - Prompt asking if you would like to perform a scan on another system
::===========================================================================================================================

SET /P ANSWER=Would you like to perform another scan (Y/N)?

Echo You chose: %ANSWER%

if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)

goto :no

:yes
Echo You pressed Yes!
@pause
goto input

:no
Echo You pressed No! Goodbye and have a great day
@pause
goto explorer

::===========================================================================================================================
::	Step 6 - Opening the Scanned_Systems directory
::===========================================================================================================================

:explorer

explorer %varpath3%

goto delfile

::===========================================================================================================================
::	Step 7 - Deleting batch file from desktop if exist
::===========================================================================================================================

:delfile

%varpath1%del_file.bat

Open in new window


On Error Resume Next

If (WScript.Arguments.Count > 0) Then
  strBaseDir = WScript.Arguments(0)
Else
  WScript.Quit
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders objFSO.GetFolder(strBaseDir)

Sub ShowSubFolders(objFolder)
    For Each objSubfolder in objFolder.SubFolders
    If objSubfolder.Size = 0 Then
        Wscript.Echo objSubfolder.Path
    End If
        ShowSubFolders objSubfolder
    Next
End Sub

Open in new window

~bp
0
 
kulisnccAuthor Commented:
I researched and found my own solution and it was the most helpful
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now