PhilBall Posted June 9, 2009 Share Posted June 9, 2009 Hi thereI have created the following which is supposed to delete delete folders from a list in an excel documentCODE; 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 scriptIf $answer = 7 Then MsgBox(0, "AutoIt", "OK. Bye!") ExitEndIf$SC = ""While 1 WinActivate("Microsoft Excel - TS.CFG.xls [Compatibility Mode]") Send("{DOWN}")send("^c")$SC = ClipGet()$dir = "P:\Tspirit\TEST\" & $SCMsgBox(0,$SC,$dir)DirRemove($dir,1)WEndExitThis does not delete the folder. The security permissions on the folder are below: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 More sharing options...
BrettF Posted June 9, 2009 Share Posted June 9, 2009 Welcome to the forums. You could use Excel.au3 and DirRemove()... Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
PhilBall Posted June 9, 2009 Author Share Posted June 9, 2009 (edited) Welcome to the forums.You could use Excel.au3 and DirRemove()... Cheers,BretthiThanks.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 June 9, 2009 by PhilBall Link to comment Share on other sites More sharing options...
BrettF Posted June 10, 2009 Share Posted June 10, 2009 In the helpfile under UDFs, Execl Management? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
PhilBall Posted June 10, 2009 Author Share Posted June 10, 2009 In the helpfile under UDFs, Execl Management? 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 More sharing options...
KaFu Posted June 10, 2009 Share Posted June 10, 2009 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now