Community
    • 登入

    How to point a file in a batchfile with a space in the filename

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    8 貼文 2 Posters 5.5k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Harm SchinkelH
      Harm Schinkel
      最後由 編輯

      Hi all,

      As a new user of NPP++ I simply want to make a batchfile with the next dos-command:

      cd d:\kopie\foto-archief harm
      On a dos commandline is should be cd d:\kopie"foto-archief harm" because DOS doesn’t recognise spaces.

      In NPP++ is doesn’t work en DOS is reading it as cd d:\kopie\foto-archief.

      How to solve this problem??

      Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
      • Claudia FrankC
        Claudia Frank @Harm Schinkel
        最後由 編輯

        Hello @Harm-Schinkel,

        how do you run the batch? Within a cmd shell? Using a plugin?

        Cheers
        Claudia

        1 條回覆 最後回覆 回覆 引用 1
        • Harm SchinkelH
          Harm Schinkel
          最後由 編輯

          Hi Claudia,

          i run the batch in the cmd shell,

          greetings,
          Harm

          1 條回覆 最後回覆 回覆 引用 0
          • Claudia FrankC
            Claudia Frank
            最後由 編輯

            Hi Harm,

            than it does exactly work as you described.
            Edit a batch like

            cd "d:\kopie\foto-archief harm"
            dir
            

            save it, run it and you should see the dir listing of the directory.

            Cheers
            Claudia

            1 條回覆 最後回覆 回覆 引用 1
            • Harm SchinkelH
              Harm Schinkel
              最後由 編輯

              Hi Claudia,

              It works !!
              strange difference by te way…

              In the cmd-box i type dir p:“foto-archief harm” and it works but NOT in Npp++
              In the cmd-box i type dir “p:\foto-archief harm” and it works AND ALSO in Npp++
              The only difference is the first quote

              But “problem solved” so thx.

              Harm

              1 條回覆 最後回覆 回覆 引用 0
              • Claudia FrankC
                Claudia Frank
                最後由 編輯

                Hi Harm,

                the difference isn’t the quote, it is the backslash.
                In your first post, I assumed you didn’t type the \ unintentionally,
                but now I see that it seems that you do this always, don’t you?

                You are using relative notation which might or might not work, depending on current directory.
                My way is absolute notation which should, as long as the path is correct/does exist, always work.

                Cheers
                Claudia

                1 條回覆 最後回覆 回覆 引用 0
                • Harm SchinkelH
                  Harm Schinkel
                  最後由 編輯

                  Hi Claudia,

                  You made me really curious :-)
                  I’m not sure if you mean the backslash at the beginning or the end so i tried 3 commandlines in a testfile. Beside i still doubt if it was the backslash or the quote.

                  cls
                  @ECHO.
                  @ECHO.
                  CLS
                  @ECHO TEST 1
                  Robocopy p:“foto-archief harm\0 Testomgeving” D:\backup\test /MIR /LOG+:H:\Dos_map\TESTLogfile.txt
                  @ECHO.
                  @ECHO.
                  @ECHO TEST 2
                  Robocopy p:“foto-archief harm\0 Testomgeving”\ D:\backup\test /MIR /LOG+:H:\Dos_map\TESTLogfile.txt
                  @ECHO.
                  @ECHO.
                  @ECHO TEST 3
                  Robocopy “p:\foto-archief harm\0 Testomgeving” D:\backup\test /MIR /LOG+:H:\Dos_map\TESTLogfile.txt
                  pause
                  cls
                  exit

                  In test 1 the dosbox told me:
                  Source: P:"foto-archief
                  Dest: H:\Dos_map\Harm\0

                  In test 2 the dosbox told me:
                  Source: P:"foto-archief
                  Dest: H:\Dos_map\Harm\0

                  In test 3 the dosbox told me:
                  Source : p:\foto-archief harm\0 Testomgeving\
                  Dest : D:\backup\test\

                  In test 3 all files are copied

                  So my conclusion is that the real problem was the quote.

                  But still thank you for your reactions, it set me to think about these items :-)

                  Greetings,
                  Harm

                  1 條回覆 最後回覆 回覆 引用 0
                  • Claudia FrankC
                    Claudia Frank
                    最後由 編輯

                    Hi Harm,

                    I may be wrong but I don’t think it is the quote, well, it isn’t the cause of the problem.
                    From cmd shell point of view all three commands should work but the main difference is the backslash
                    after the disk letter.
                    Test 1 and 2 are the same but 3 is different in the meaning how path should be interpreted.

                    From shells point of view

                     p:“foto-archief harm\0 Testomgeving” 
                    

                    means that there is a subdirectory foto-archief harm which again has a subdirectory 0 Testomgeving on drive p: relative
                    to the current directory.

                    Let’s assume that I want to get a list of all txt files in the python\npp directory which is a subdirectory of d:\scripts.
                    I could easily do this by executing of of the following dir commands

                    D:\scripts>dir /B python\npp\*.txt
                    dummy.txt
                    
                    D:\scripts>dir /B "python\npp\*.txt"
                    dummy.txt
                    
                    D:\scripts>dir /B "d:python\npp\*.txt"
                    dummy.txt
                    
                    D:\scripts>dir /B d:"python\npp\*.txt"
                    dummy.txt
                    

                    but what I can’t do is using this form

                    D:\scripts>dir /B d:\"python\npp\*.txt"
                    The system cannot find the path specified.
                    
                    D:\scripts>dir /B "d:\python\npp\*.txt"
                    The system cannot find the path specified.
                    

                    Because the latter are absolute paths. A absolute path begins either

                    • with two backslashes (UNC)
                    • with a disk letter, colon AND a backslash
                    • with a backslash.

                    Your notation p:foto-archief harm is relative. So if your current directory is p:\dir1\dir2
                    and there is a subdirectory foto-archief harm a dir p:foto-archief harm\ would do a listing in p:\dir1\dir2\foto-archief harm.
                    So if you do a fourth test

                    Robocopy p:\"foto-archief harm\0 Testomgeving" D:\backup\test /MIR /LOG+:H:\Dos_map\TESTLogfile.txt
                    

                    you will see it works as well.

                    Cheers
                    Claudia

                    1 條回覆 最後回覆 回覆 引用 0
                    • 第一個貼文
                      最後的貼文
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors