Community
    • Login

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

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 2 Posters 5.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Harm SchinkelH
      Harm Schinkel
      last edited by

      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 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Harm Schinkel
        last edited by

        Hello @Harm-Schinkel,

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

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 1
        • Harm SchinkelH
          Harm Schinkel
          last edited by

          Hi Claudia,

          i run the batch in the cmd shell,

          greetings,
          Harm

          1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank
            last edited by

            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 Reply Last reply Reply Quote 1
            • Harm SchinkelH
              Harm Schinkel
              last edited by

              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 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank
                last edited by

                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 Reply Last reply Reply Quote 0
                • Harm SchinkelH
                  Harm Schinkel
                  last edited by

                  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 Reply Last reply Reply Quote 0
                  • Claudia FrankC
                    Claudia Frank
                    last edited by

                    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 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors