“specifically: inactive” when running a script?

Get help with using AutoHotkey and its commands and hotkeys
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

“specifically: inactive” when running a script?

17 Jan 2021, 10:29

This is a problem with the third line of the script [the "Loop, Files," area]

Can anyone tell me what im doing wrong here? I get this message when running the script https://i.imgur.com/xNZPmwh.png

Code: Select all

;Deletes all .txt Files in this folder that doesnt contain any of these words [capitalized or non-capitalized] in line 10 or 11

Loop, Files, C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\*.txt
{
    f1 := A_LoopFilePath
    FileReadLine, line10, % f1, 10
    erl_1 := ErrorLevel
    FileReadLine, line11, % f1, 11
    erl_2 := ErrorLevel
    if !(erl_1 || erl_2) && !(line10 ~= "i)Day|marbles|popsicles" && line11 ~= "i)night|bubbles")
        FileDelete, % f1
}

gregster
Posts: 5837
Joined: 30 Sep 2013, 06:48

Re: “specifically: inactive” when running a script?

17 Jan 2021, 10:33

It means, Inactive doesn't make sense as the third parameter of a Loop, Files statement, it's no valid syntax.
Please compare: https://www.autohotkey.com/docs/commands/LoopFile.htm
Btw, this also means that the fourth and fifth parameter are not part of its syntax.
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: “specifically: inactive” when running a script?

17 Jan 2021, 11:27

Am I right in saying I should change it to this then?

Code: Select all

FileList := ""
Loop, Files, %C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\*.txt\*.*, FD  ; Include Files and Directories
{
    f1 := A_LoopFilePath
    FileReadLine, line10, % f1, 10
    erl_1 := ErrorLevel
    FileReadLine, line11, % f1, 11
    erl_2 := ErrorLevel
    if !(erl_1 || erl_2) && !(line10 ~= "i)Day|marbles|popsicles" && line11 ~= "i)night|bubbles")
        FileDelete, % f1
}
User avatar
boiler
Posts: 6872
Joined: 21 Dec 2014, 02:44

Re: “specifically: inactive” when running a script?

17 Jan 2021, 11:32

It appears your path has commas in it, so I think you’re looking to do this (force an expression so you can use a quoted string):

Code: Select all

Loop, Files, % "C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\*.txt\*.*", FD  ; Include Files and Directories
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: “specifically: inactive” when running a script?

17 Jan 2021, 12:26

Thanks, that runs fine but it's not deleting any txt files for some reason

Code: Select all

FileList := ""
Loop, Files, % "C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\*.txt\*.*", FD  ; Include Files and Directories
{
    f1 := A_LoopFilePath
    FileReadLine, line10, % f1, 10
    erl_1 := ErrorLevel
    FileReadLine, line11, % f1, 11
    erl_2 := ErrorLevel
    if !(erl_1 || erl_2) && !(line10 ~= "i)night|marbles|popsicles" && line11 ~= "i)night|bubbles")
        FileDelete, % f1
}

while this one I was using previously [which focuses only on a particular file, not all files in the folder] works fine

Code: Select all

;Deletes  File that doesnt contain any of these words [capitalized or non-capitalized] in line 10 or 11

f1 := "C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\test_1537.txt"
FileReadLine, line10, % f1, 10
erl_1 := ErrorLevel
FileReadLine, line11, % f1, 11
erl_2 := ErrorLevel
if !(erl_1 || erl_2) && !(line10 ~= "i)night|marbles|popsicles" && line11 ~= "i)night|bubbles")
   FileDelete, % f1
any idea what I'm doing wrong with the first script, why it won't delete the txt files that don't match the criteria?
User avatar
mikeyww
Posts: 5368
Joined: 09 Sep 2014, 18:38

Re: “specifically: inactive” when running a script?

17 Jan 2021, 12:30

In a case like this, a debugging strategy is to see what files are being processed. I imagine that none are being found in your case, and that you want to change:

\*.txt\*.*

to:

\*.txt
autohotkeycool
Posts: 89
Joined: 24 May 2016, 08:23

Re: “specifically: inactive” when running a script?

17 Jan 2021, 12:33

Thanks I fixed that there, but it still doesn't work properly for some reason

Code: Select all

FileList := ""
Loop, Files, % "C:\PortableApps Platform\PortableApps\AutoHotkeyPortable\Scripts\Old, Inactive, Faulty, Tests\Tests\*.txt", FD  ; Include Files and Directories
{
    f1 := A_LoopFilePath
    FileReadLine, line10, % f1, 10
    erl_1 := ErrorLevel
    FileReadLine, line11, % f1, 11
    erl_2 := ErrorLevel
    if !(erl_1 || erl_2) && !(line10 ~= "i)night|marbles|popsicles" && line11 ~= "i)night|bubbles")
        FileDelete, % f1
}
User avatar
mikeyww
Posts: 5368
Joined: 09 Sep 2014, 18:38

Re: “specifically: inactive” when running a script?

17 Jan 2021, 12:38

Debug by breaking down the script into parts that you can inspect and understand. You can add the following debugging steps.

1. Find out which files are being processed.

2. Find out what the ErrorLevel values are.

3. Check each of the RegEx matches to see if there is really a match.

4. See what the ErrorLevel is after FileDelete.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], demon12, hasantr, paul1965, roysubs, vmech and 66 guests