I want to copy all files from one folder to another, by dragging and dropping the source folder onto a batch file.
copy "%1%\*.*" c:\nickdocs\*.*
However if there is a gap in the path name or or folder name of the source, the batch file says "The system cannot find the file specified"
For instance if I use c:\Input 1 as my source, the result is
""C:\Input 1"\nickdocs\*.*
"The system cannot find the file specified"
and there it ends
Can anyone point me with this?
Thanks for any help
Nick
Page 1 of 1
Batch File to work with gaps
#2
Posted 17 March 2009 - 05:40 AM
You should place one more set of inverted commas (" "). For example,
copy ""%1\*.*"" c:\nickdocs\*.*
#3
Posted 17 March 2009 - 05:48 AM
Thanks for that!
I _thought_ I had tried that, but I will give it a go.
Lettyano.
Nick
I _thought_ I had tried that, but I will give it a go.
Lettyano.
Nick
#5
Posted 17 March 2009 - 12:18 PM
Hello OldNick,
In this case, I think you want the following line in your batch file:
1. If the name of the folder/directory you're dragging to the batch file does not contain any spaces (e.g., "ABC"), the command will expand to:
which is what you want.
2. If the name of the folder/directory you're dragging to the batch file does contain spaces (e.g., "ABC 123 XYZ"), the command will expand to:
which does work. Evidently, in the process of dragging a folder name containing spaces to your batch file, the system automatically supplies the surrounding quotes if it detects that the folder name (argument to the batch file) contains any spaces.
Also note that the command, as written above, will copy only the top-level files -- it will not copy any subfolders.
In this case, I think you want the following line in your batch file:
copy %1\*.* c:\nickdocs\*.*
1. If the name of the folder/directory you're dragging to the batch file does not contain any spaces (e.g., "ABC"), the command will expand to:
copy C:\ABC\*.* c:\nickdocs\*.*
which is what you want.
2. If the name of the folder/directory you're dragging to the batch file does contain spaces (e.g., "ABC 123 XYZ"), the command will expand to:
copy "C:\ABC 123 XYZ"\*.* c:\nickdocs\*.*
which does work. Evidently, in the process of dragging a folder name containing spaces to your batch file, the system automatically supplies the surrounding quotes if it detects that the folder name (argument to the batch file) contains any spaces.
Also note that the command, as written above, will copy only the top-level files -- it will not copy any subfolders.
#6
Posted 17 March 2009 - 02:34 PM

It appears you are doing something wrong...
#7
Posted 17 March 2009 - 04:12 PM
So it would appear. BUT now I am being told to both add "" and to take them away.
You can see my code. So _what_ am I doping wrong?
You can see my code. So _what_ am I doping wrong?
#8
Posted 17 March 2009 - 05:18 PM
In this case (dragging and dropping), either one will work.
In the screen snapshot below, the first "copy" command shows the expansion and execution of the version I posted above. The second "copy" command shows the expansion and execution of the version posted by Romeo29 above:
http://img14.imageshack.us/img14/6969/scrn003.png
In the screen snapshot below, the first "copy" command shows the expansion and execution of the version I posted above. The second "copy" command shows the expansion and execution of the version posted by Romeo29 above:
http://img14.imageshack.us/img14/6969/scrn003.png
Share this topic:
Page 1 of 1

Help

Back to top









