Loop, files and (Back)slashes

Get help with using AutoHotkey and its commands and hotkeys
Peter2
Posts: 243
Joined: 21 Sep 2014, 14:38
Location: CH

Loop, files and (Back)slashes

17 Feb 2016, 19:03

I made a mistake with (back)slashes, and I'm curious why I get the results I got.

I defined a folder, using slashes instead of backslashes:

Code: Select all

ziel1 := A_AppData . "/Autodesk/ApplicationPlugins/"
In this folders, there are the subfolders "A.bundle", "B.bundle_paused" and "C"
Then I looped the folder, to get its subfolders

Code: Select all

    Loop, Files, %ziel1%*.*, D
    {
        MsgBox %A_LoopFileName%
        If A_LoopFileExt in bundle,bundle_paused    ; 
        {
            XML_File = %A_LoopFileDir%\PackageContents.xml
            msgbox %XML_File%
The first MsgBox showed me (step by step) the folders "A.bundle", "B.bundle_paused" and "C". That's fine
The second MsgBox was expected to show me the same value as "ziel1 plus filename", because the folders where found there. But I got only "C:\users\peter2\Appdata\packageContents.xml" (same result with A_LoopFileFullPath and A_LoopFileLongPath).

After I modified the slashes to backslashes everything was fine. Now I would like to know why the first step had no problems with the slashes, but the second step shortened the paths ...???

Thanks for your help.
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

Re: Loop, files and (Back)slashes

17 Feb 2016, 20:02

Consider the output from the SplitPath command:

Code: Select all

^8::
InputVar:= "C:\users\peter2\Appdata/Autodesk/ApplicationPlugins/"
SplitPath, InputVar, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
MsgBox % OutFileName "`n" OutDir "`n" OutExtension "`n" OutNameNoExt "`n" OutDrive
return
OutDir comes back as just C:\users\peter2\. I assume the built in variable A_LoopFileDir follows the same algorithm SplitPath does to determine the directory.

But when it was doing a loop file, it could handle the / in there as it queries an API that has support for that to navigate folders. I can type into my Windows Explorer "C:/Users/Exaskryz/Desktop" and be brought to the right location. Clicking on the navbar again will give me the corrected address with \ in there.
Peter2
Posts: 243
Joined: 21 Sep 2014, 14:38
Location: CH

Re: Loop, files and (Back)slashes

18 Feb 2016, 02:55

Thanks for your help.
So it can be said that "Loop, Files" handles the path in another way than "A_LoopFileDir"?
Peter (AHK Beginner) / Win 7 x64, AHK Version v1.1.22.xx

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], don_dolarson, flyingDman, Google [Bot], grimboto and 200 guests