Jump to content

DirRemove help


Recommended Posts

Hi there

I have created the following which is supposed to delete delete folders from a list in an excel document

CODE

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will run a batch file to delete data directory folders. Do you wish to continue?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "AutoIt", "OK. Bye!")

Exit

EndIf

$SC = ""

While 1

WinActivate("Microsoft Excel - TS.CFG.xls [Compatibility Mode]")

Send("{DOWN}")

send("^c")

$SC = ClipGet()

$dir = "P:\Tspirit\TEST\" & $SC

MsgBox(0,$SC,$dir)

DirRemove($dir,1)

WEnd

Exit

This does not delete the folder. The security permissions on the folder are below:

Posted Image

Posted Image

It worked OK yesterday, but I have mucking about trying to get the loop to stop at the end of the excell list, to no avail and now the delete function does not work!!!

Can anyone help?

Thanks, Phil

Link to comment
Share on other sites

Welcome to the forums.

You could use Excel.au3 and DirRemove()... :D

Cheers,

Brett

hi

Thanks.

Where would I find Excel.au3?

I was using DirRemove in the quoted code. I think there was a problem using the variable in the DirRemove function. I used excel to create the 479 lines of DirRemove (one for each folder) and pasted them and it worked, instead of going through a loop. Not the best practice, but a solution!

I would like to know what I was doing wrong, not used to the looping strings either......

Phil

Edited by PhilBall
Link to comment
Share on other sites

In the helpfile under UDFs, Execl Management? :D

Thanks for your help. But it does not really answer my question.

My problem was with the variable $SC contains the folder name and I add it to the end of $dir and the MsgBox confirms this has worked correctly, but when I use the variable $dir in DirRemove, it does not work and I know it did work before.

Link to comment
Share on other sites

Maybe it has something to do with dir attributes?

Remarks in Helpfile for Dirremove(): "Some dir attributes can make the removal impossible"

CODE

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)

$answer = MsgBox(4, "AutoIt Example (English Only)", "This script will run a batch file to delete data directory folders. Do you wish to continue?")

; Check the user's answer to the prompt (see the help file for MsgBox return values)

; If "No" was clicked (7) then exit the script

If $answer = 7 Then

MsgBox(0, "AutoIt", "OK. Bye!")

Exit

EndIf

$SC = ""

While 1

WinActivate("Microsoft Excel - TS.CFG.xls [Compatibility Mode]")

Send("{DOWN}")

Send("^c")

$SC = ClipGet()

$dir = "P:\Tspirit\TEST\" & $SC

ClipPut($dir)

MsgBox(0, $SC, $dir)

MsgBox(0, "Fileattrib" & $SC, FileGetAttrib($dir)) ; FileSetAttrib if R

FileSetAttrib($dir,"-R",1)

MsgBox(0, "Remove" & $SC, DirRemove($dir, 1))

WEnd

Exit

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...