how do I combine 2 batch commands?

February 16, 2017 at 06:58:48
Specs: Windows 7
I need a batch file that can move all the file from one folder to another and make then all read only.

See More: how do I combine 2 batch commands?

Report •

February 16, 2017 at 13:01:39
Question: Can you get away with just making everything in the destination read only?

How To Ask Questions The Smart Way

message edited by Razor2.3

Report •

February 17, 2017 at 00:53:54

echo %time% & dir & echo %time%

This is, from memory, equivalent to the semi-colon separator in bash and other UNIXy shells.

There's also && (or ||) which only executes the second command if the first succeeded (or failed), but the single ampersand & is what you're looking for here.

That's likely to give you the same time however since environment variables tend to be evaluated on read rather than execute.

You can get round this by turning on delayed expansion:

pax> cmd /v:on /c "echo !time! & ping >nul: & echo !time!"

That's needed from the command line. If you're doing this inside a script, you can just use setlocal:

@setlocal enableextensions enabledelayedexpansion
@echo off
echo !time! & ping >nul: & echo !time!

Report •

April 8, 2017 at 03:02:27
move /y *.* d:\somefold & attrib +r d:\somefold\*.*


M2 Get custom script or take private lessons

Report •
Related Solutions

Ask Question