Jump to content

cmd to Autoit #2


 Share

Go to solution Solved by ioa747,

Recommended Posts

@echo off
::----------------
set oldPath=D:\Main\
set folders=(First Second Third Fourth Fifth)
::----------------
for %%f in %folders% do (
if exist %oldPath%%%f\ rd %oldPath%%%f\ /q /s
echo Removed: %oldPath%%%f\
)
echo Cleaning folders completed...
::----------------

I have this...

;-----------------------------------------------
#include <AutoItConstants.au3>
;-----------------------------------------------
;Non-Loop Version
_DeleteFolders
;-----------------------------------------------
Func _DeleteFolders()
    Local $oldPath = "D:\Main"
    Local $folder1 = "First"
    Local $folder2 = "Second"
    Local $folder3 = "Third"
    Local $folder4 = "Fourth"
    Local $folder5 = "Fifth"
    ;-----------------------------------------------
    DirRemove($oldPath & "\" & $folder1, $DIR_REMOVE)
    DirRemove($oldPath & "\" & $folder2, $DIR_REMOVE)
    DirRemove($oldPath & "\" & $folder3, $DIR_REMOVE)
    DirRemove($oldPath & "\" & $folder4, $DIR_REMOVE)
    DirRemove($oldPath & "\" & $folder5, $DIR_REMOVE)
    SplashTextOn("Notice!", "Cleaning folders completed...", 350, 50, -1, -1)
    Sleep(2000)
EndFunc   ;==>_DeleteFolders
;-----------------------------------------------

 

Link to comment
Share on other sites

  • Solution

like

#include <AutoItConstants.au3>

Local $oldPath = "D:\Main"

Local $afolders = "First, Second, Third, Fourth, Fifth"
$afolders = StringSplit($afolders, ", ", 1)
For $i = 1 To $afolders[0]
    ;DirRemove($oldPath & "\" & $afolders[$i], $DIR_REMOVE)
    ConsoleWrite("-> Remove: " & $oldPath & "\" & $afolders[$i] & @CRLF)
Next

 

I know that I know nothing

Link to comment
Share on other sites

ioa747,

...like..."Yes!"...Very much so!

Thanks for this, ioa747...very much appreciated!

Note: Regarding the HelpFile, though that text can at times, indeed be Help-Full, lack of various examples is also, sorely lacking! The example that ioa747 provided not only displays what I would refer to as "a practical example", but also display "other things" that makes further investigation extremely likely! For example:

1) Local $afolders = "First, Second, Third, Fourth, Fifth": Shows an interesting usage of multiple variables.
2) How to apply a For...To-..Next command
3) A practical use of StringSplit
4) A practical application of "other commands" - instead of focusing entirely on the use of Msgbox's.

As a "point-of-interest", instruction should never, ever be "assumptive". Just because one "gets it"...should NOT infer or imply that someone else is going to "gets it" as well. A wise  instructor takes a hand and then opens the heart. Without sounds too corny, ioa747 has certainly opened this heart! Thanks ioa747!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...