How to point a file in a batchfile with a space in the filename
-
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??
-
-
Hi Claudia,
i run the batch in the cmd shell,
greetings,
Harm -
Hi Harm,
than it does exactly work as you described.
Edit a batch likecd "d:\kopie\foto-archief harm" dir
save it, run it and you should see the dir listing of the directory.
Cheers
Claudia -
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 quoteBut “problem solved” so thx.
Harm
-
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 -
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
exitIn test 1 the dosbox told me:
Source: P:"foto-archief
Dest: H:\Dos_map\Harm\0In test 2 the dosbox told me:
Source: P:"foto-archief
Dest: H:\Dos_map\Harm\0In 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 -
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 commandsD:\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 testRobocopy 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