Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
VespaGS150
- Posts: 8
- Joined: 13 Jul 2016 09:32
#16
Post
by VespaGS150 » 19 Jul 2016 07:40
Squashman wrote:VespaGS150 wrote:Here you are my code. Where I can put the /B switch?
set snfFrom=C:\FolderA\File.bak
set snfTo=C:\FolderB\File.bak
if exist %snfTo% goto mExist
copy %snfFrom% %snfTo%
goto mEx
:mExist
copy %snfTo%+%snfFrom% %snfTo%
:mEx
If you happened to read the help for the COPY command you will notice that the /B option can be used for SOURCE and DESTINATION.
Code: Select all
H:\>copy /?
Copies one or more files to another location.
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
if exist %snfTo% goto mExist
copy /b %snfFrom% %snfTo% /b
goto mEx
:mExist
copy %snfTo%+%snfFrom% %snfTo%
:mEx
But it doesn't work
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#17
Post
by foxidrive » 19 Jul 2016 11:20
Squashman wrote:If you happened to read the help for the COPY command
That's a fanciful notion Squashman. People these days reading help for commands? It's more likely that SETI will find a whole mess of intelligent life.
VespaGS150, try this code to begin with. It's all you really need for your situation due to the way append works.
Code: Select all
type "C:\Folder1\FileA.txt" >> "C:\Folder2\FileB.txt"
-
VespaGS150
- Posts: 8
- Joined: 13 Jul 2016 09:32
#18
Post
by VespaGS150 » 20 Jul 2016 01:36
foxidrive wrote:Squashman wrote:If you happened to read the help for the COPY command
That's a fanciful notion Squashman. People these days reading help for commands? It's more likely that SETI will find a whole mess of intelligent life.
VespaGS150, try this code to begin with. It's all you really need for your situation due to the way append works.
Code: Select all
type "C:\Folder1\FileA.txt" >> "C:\Folder2\FileB.txt"
Mmm I have tried with the code below but I have still the highlighted character
set snfFrom=C:\Selesta\SeleP2000\SeleP2000.bak
set snfTo=C:\Selesta\Timbra\SeleP2000.bak
if exist %snfTo% goto mExist
%snfFrom% >> %snfTo%
goto mEx
:mExist
copy %snfTo%+%snfFrom% %snfTo%
:mEx
-
VespaGS150
- Posts: 8
- Joined: 13 Jul 2016 09:32
#20
Post
by VespaGS150 » 21 Jul 2016 02:50
foxidrive wrote:Try this code.
Code: Select all
type "C:\Folder1\FileA.txt" >> "C:\Folder2\FileB.txt"
Amazing! I'm a stupid: I thought that "type" is not part of the code
It works!!!
Many many thanks guys!
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#21
Post
by foxidrive » 21 Jul 2016 13:26
VespaGS150 wrote:I thought that "type" is not part of the code
It works!!!
Many many thanks guys!
Thanks.
Lesson number one in life says "When you don't understand then ask questions"