QuestionId
stringlengths
3
8
QuestionTitle
stringlengths
15
149
QuestionScore
int64
1
27.2k
QuestionCreatedUtc
stringdate
2008-08-01 18:33:08
2025-06-16 04:59:48
QuestionBodyHtml
stringlengths
40
28.2k
QuestionViewCount
int64
78
16.5M
QuestionOwnerUserId
float64
4
25.2M
QuestionLastActivityUtc
stringdate
2008-09-08 19:26:01
2026-01-24 22:40:25
AcceptedAnswerId
int64
266
79.7M
AnswerScore
int64
2
30.1k
AnswerCreatedUtc
stringdate
2008-08-01 23:40:28
2025-06-16 05:23:39
AnswerOwnerUserId
float64
1
29.5M
AnswerLastActivityUtc
stringdate
2008-08-01 23:40:28
2026-01-23 17:46:09
QuestionLink
stringlengths
31
36
AnswerLink
stringlengths
31
36
AnswerBodyHtml
stringlengths
35
33k
AnswerBodyPreview
stringlengths
35
400
AllTagIdsCsv
stringlengths
2
37
AllTagNamesCsv
stringlengths
2
106
MergedQuestion
stringlengths
74
28.4k
quality_filter
stringclasses
10 values
unique_id
int64
0
29k
tag_major_lang
stringclasses
10 values
MergedQuestion_md
stringlengths
60
28.1k
AnswerBodyHtml_md
stringlengths
14
29.2k
864718
How to append a date in batch files
50
2009-05-14 17:40:32
<p>I have the following line in a batch file (that runs on an old <a href="http://en.wikipedia.org/wiki/Windows_2000" rel="noreferrer">Windows 2000</a> box):</p> <pre><code>7z a QuickBackup.zip *.backup </code></pre> <p>How do I append the date to the <code>QuickBackup.zip</code> file. So if I ran the batch file toda...
263,343
9,382
2023-05-17 06:29:41
865,568
62
2009-05-14 20:29:56
107,310
2012-02-07 20:37:15
https://stackoverflow.com/q/864718
https://stackoverflow.com/a/865568
<p><a href="https://stackoverflow.com/a/864743/144669">Bernhard's answer</a> needed some tweaking work for me because the %DATE% environment variable is in a different format (as commented elsewhere). Also, there was a tilde (~) missing.</p> <p>Instead of:</p> <blockquote> <p><code>set backupFilename=%DATE:~6,4%%DA...
<p><a href="https://stackoverflow.com/a/864743/144669">Bernhard's answer</a> needed some tweaking work for me because the %DATE% environment variable is in a different format (as commented elsewhere). Also, there was a tilde (~) missing.</p> <p>Instead of:</p> <blockquote> <p><code>set backupFilename=%DATE:~6,4%%DA...
64, 7002
batch-file, windows
<h1>How to append a date in batch files</h1> <p>I have the following line in a batch file (that runs on an old <a href="http://en.wikipedia.org/wiki/Windows_2000" rel="noreferrer">Windows 2000</a> box):</p> <pre><code>7z a QuickBackup.zip *.backup </code></pre> <p>How do I append the date to the <code>QuickBackup.zip...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,198
cmd
# How to append a date in batch files I have the following line in a batch file (that runs on an old [Windows 2000](http://en.wikipedia.org/wiki/Windows_2000) box): ``` 7z a QuickBackup.zip *.backup ``` How do I append the date to the `QuickBackup.zip` file. So if I ran the batch file today, ideally, the file would ...
[Bernhard's answer](https://stackoverflow.com/a/864743/144669) needed some tweaking work for me because the %DATE% environment variable is in a different format (as commented elsewhere). Also, there was a tilde (~) missing. Instead of: > `set backupFilename=%DATE:~6,4%%DATE:~3,2%%DATE:0,2%` I had to use: > `set bac...
23447948
How Spring Boot run batch jobs
44
2014-05-03 17:52:01
<p>I followed <a href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-batch/src/main/java/sample/batch/SampleBatchApplication.java" rel="noreferrer">this sample</a> for Spring Batch with Boot.</p> <p>When you run the main method the job is executed. This way I can't ...
36,506
383,087
2018-06-19 03:11:38
23,448,661
62
2014-05-03 19:04:35
383,087
2014-05-03 19:04:35
https://stackoverflow.com/q/23447948
https://stackoverflow.com/a/23448661
<p>The jobs execution can be prevented by setting</p> <pre><code>spring.batch.job.enabled=false </code></pre> <p>in application.properties. Or you can use <code>spring.batch.job.names</code> it takes a comma-delimited list of job names that will be run.</p> <p>Taken from here: <a href="https://stackoverflow.com/ques...
<p>The jobs execution can be prevented by setting</p> <pre><code>spring.batch.job.enabled=false </code></pre> <p>in application.properties. Or you can use <code>spring.batch.job.names</code> it takes a comma-delimited list of job names that will be run.</p> <p>Taken from here: <a href="https://stackoverflow.com/ques...
17, 1211, 41895, 95875
java, spring, spring-batch, spring-boot
<h1>How Spring Boot run batch jobs</h1> <p>I followed <a href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-batch/src/main/java/sample/batch/SampleBatchApplication.java" rel="noreferrer">this sample</a> for Spring Batch with Boot.</p> <p>When you run the main method...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,199
cmd
# How Spring Boot run batch jobs I followed [this sample](https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-batch/src/main/java/sample/batch/SampleBatchApplication.java) for Spring Batch with Boot. When you run the main method the job is executed. This way I can't figur...
The jobs execution can be prevented by setting ``` spring.batch.job.enabled=false ``` in application.properties. Or you can use `spring.batch.job.names` it takes a comma-delimited list of job names that will be run. Taken from here: [how to stop spring batch scheduled jobs from running at first time when executing t...
30406136
Remove proxy settings from the windows command prompt
38
2015-05-22 21:28:55
<p>I had set proxy settings in cmd when I was in a proxy network as follows:</p> <p><code>set http_proxy=http://username:pass@hostname:port</code></p> <p><code>set https_proxy=https://username:pass@hostname:port</code></p> <p>Now that I am on a normal network I want to unset the proxy settings in the command prompt....
249,346
3,079,419
2023-04-24 01:30:31
33,843,806
62
2015-11-21 13:18:15
5,589,186
2015-11-21 15:50:40
https://stackoverflow.com/q/30406136
https://stackoverflow.com/a/33843806
<p>try,</p> <pre><code>set http_proxy= set https_proxy= </code></pre>
<p>try,</p> <pre><code>set http_proxy= set https_proxy= </code></pre>
64, 760, 2631, 9938, 24756
cmd, command-prompt, http-proxy, proxy, windows
<h1>Remove proxy settings from the windows command prompt</h1> <p>I had set proxy settings in cmd when I was in a proxy network as follows:</p> <p><code>set http_proxy=http://username:pass@hostname:port</code></p> <p><code>set https_proxy=https://username:pass@hostname:port</code></p> <p>Now that I am on a normal ne...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,200
cmd
# Remove proxy settings from the windows command prompt I had set proxy settings in cmd when I was in a proxy network as follows: `set http_proxy=http://username:pass@hostname:port` `set https_proxy=https://username:pass@hostname:port` Now that I am on a normal network I want to unset the proxy settings in the comm...
try, ``` set http_proxy= set https_proxy= ```
10948235
taskkill window spaces in its title name
38
2012-06-08 11:46:30
<p>I'm trying to run taskkill on a console window that has spaces in it's title. How can I pass this window title to taskkill. I have tried the following:</p> <pre><code>taskkill /fi "WINDOWTITLE eq Administrator: My Window Title" </code></pre>
66,822
1,086,117
2020-06-30 00:28:30
15,408,480
62
2013-03-14 11:51:48
706,561
2017-02-13 21:25:28
https://stackoverflow.com/q/10948235
https://stackoverflow.com/a/15408480
<p>I've had similar problems, but found out a little bit more.</p> <h2>Problem</h2> <p>I have been trying to close a CMD window (run as administrator) which has set its own window title. So, run CMD as administrator and type:</p> <pre><code>title CMD with custom title </code></pre> <p>After much faffing, the follo...
<p>I've had similar problems, but found out a little bit more.</p> <h2>Problem</h2> <p>I have been trying to close a CMD window (run as administrator) which has set its own window title. So, run CMD as administrator and type:</p> <pre><code>title CMD with custom title </code></pre> <p>After much faffing, the follo...
64, 2631, 7002
batch-file, cmd, windows
<h1>taskkill window spaces in its title name</h1> <p>I'm trying to run taskkill on a console window that has spaces in it's title. How can I pass this window title to taskkill. I have tried the following:</p> <pre><code>taskkill /fi "WINDOWTITLE eq Administrator: My Window Title" </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,201
cmd
# taskkill window spaces in its title name I'm trying to run taskkill on a console window that has spaces in it's title. How can I pass this window title to taskkill. I have tried the following: ``` taskkill /fi "WINDOWTITLE eq Administrator: My Window Title" ```
I've had similar problems, but found out a little bit more. ## Problem I have been trying to close a CMD window (run as administrator) which has set its own window title. So, run CMD as administrator and type: ``` title CMD with custom title ``` After much faffing, the following command showed me that setting the w...
43080312
'csc' is not recognized as an internal or external command, operable program or batch file
36
2017-03-28 21:30:29
<p>I'm fairly new to C# and I'm trying to use cmd to compile a basic hello world file called <code>test.cs</code>. It contains the following:</p> <pre><code>// Similar to #include&lt;foo.h&gt; in C++, includes system namespaces in a program using System; using System.Collections.Generic; using System.Linq...
72,756
4,986,641
2017-03-28 21:44:10
43,080,377
62
2017-03-28 21:35:43
3,482,140
2017-03-28 21:41:11
https://stackoverflow.com/q/43080312
https://stackoverflow.com/a/43080377
<p>Locate the path of csc.exe and add it your <code>PATH</code> environment variable.</p> <p>In my case, the path for 64-bit C# compiler is <code>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</code>.</p> <p>Similarly, you can look for 32-bit C# compiler in <code>C:\Windows\Microsoft.NET\Framework</code> under diff...
<p>Locate the path of csc.exe and add it your <code>PATH</code> environment variable.</p> <p>In my case, the path for 64-bit C# compiler is <code>C:\Windows\Microsoft.NET\Framework64\v4.0.30319</code>.</p> <p>Similarly, you can look for 32-bit C# compiler in <code>C:\Windows\Microsoft.NET\Framework</code> under diff...
9, 2631, 6268, 9013, 19888
c#, cmd, csc, environment-variables, path
<h1>'csc' is not recognized as an internal or external command, operable program or batch file</h1> <p>I'm fairly new to C# and I'm trying to use cmd to compile a basic hello world file called <code>test.cs</code>. It contains the following:</p> <pre><code>// Similar to #include&lt;foo.h&gt; in C++, includes system na...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,202
cmd
# 'csc' is not recognized as an internal or external command, operable program or batch file I'm fairly new to C# and I'm trying to use cmd to compile a basic hello world file called `test.cs`. It contains the following: ``` // Similar to #include<foo.h> in C++, includes system namespaces in a program using Syst...
Locate the path of csc.exe and add it your `PATH` environment variable. In my case, the path for 64-bit C# compiler is `C:\Windows\Microsoft.NET\Framework64\v4.0.30319`. Similarly, you can look for 32-bit C# compiler in `C:\Windows\Microsoft.NET\Framework` under different .NET framework version directories There wil...
16128869
How to rename file by replacing substring using batch in Windows
32
2013-04-21 07:21:33
<p>I want to rename file name like <em>"how-to-<strong>rename</strong>-file.jpg"</em> to <em>"how-to-<strong>reuse</strong>-file.jpg"</em> by using a Windows batch file</p> <p>I.e. I only want to replace one or two words in a file name.</p>
116,299
1,608,477
2015-01-14 12:53:30
16,128,973
62
2013-04-21 07:40:10
1,248,295
2013-04-21 11:15:44
https://stackoverflow.com/q/16128869
https://stackoverflow.com/a/16128973
<pre><code>@echo off Set "Filename=how-to-rename-file.jpg" Set "Pattern=rename" Set "Replace=reuse" REM Call Rename "%Filename%" "%%Filename:%Pattern%=%Replace%%%" Call Echo %%Filename:%Pattern%=%Replace%%% :: Result: how-to-reuse-file.jpg Pause&amp;Exit </code></pre> <p>I give you other example for a loop of file...
<pre><code>@echo off Set "Filename=how-to-rename-file.jpg" Set "Pattern=rename" Set "Replace=reuse" REM Call Rename "%Filename%" "%%Filename:%Pattern%=%Replace%%%" Call Echo %%Filename:%Pattern%=%Replace%%% :: Result: how-to-reuse-file.jpg Pause&amp;Exit </code></pre> <p>I give you other example for a loop of file...
64, 139, 4510, 5310, 7002
batch-file, file, rename, string, windows
<h1>How to rename file by replacing substring using batch in Windows</h1> <p>I want to rename file name like <em>"how-to-<strong>rename</strong>-file.jpg"</em> to <em>"how-to-<strong>reuse</strong>-file.jpg"</em> by using a Windows batch file</p> <p>I.e. I only want to replace one or two words in a file name.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,203
cmd
# How to rename file by replacing substring using batch in Windows I want to rename file name like *"how-to-**rename**-file.jpg"* to *"how-to-**reuse**-file.jpg"* by using a Windows batch file I.e. I only want to replace one or two words in a file name.
``` @echo off Set "Filename=how-to-rename-file.jpg" Set "Pattern=rename" Set "Replace=reuse" REM Call Rename "%Filename%" "%%Filename:%Pattern%=%Replace%%%" Call Echo %%Filename:%Pattern%=%Replace%%% :: Result: how-to-reuse-file.jpg Pause&Exit ``` I give you other example for a loop of files: > UPDATE: I've miss...
3666740
Windows Batch: How to add Host-Entries?
30
2010-09-08 10:25:40
<p>I want to use this batch script to add new entries into my host file automatically by using <a href="/questions/tagged/windows" class="post-tag" title="show questions tagged &#39;windows&#39;" rel="tag">windows</a> batch.</p> <p>Unfortunately, the script <strong>just adds one single line to the hosts file</strong>,...
123,696
365,265
2026-01-01 16:56:06
10,665,562
62
2012-05-19 13:27:01
1,405,128
2012-05-19 13:27:01
https://stackoverflow.com/q/3666740
https://stackoverflow.com/a/10665562
<p>I would do it this way, so you won't end up with duplicate entries if the script is run multiple times.</p> <pre><code>@echo off SET NEWLINE=^&amp; echo. FIND /C /I "ns1.intranet.de" %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^62.116.159.4 ns1.intranet.de&gt;&gt;%WINDIR%\System32\driv...
<p>I would do it this way, so you won't end up with duplicate entries if the script is run multiple times.</p> <pre><code>@echo off SET NEWLINE=^&amp; echo. FIND /C /I "ns1.intranet.de" %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^62.116.159.4 ns1.intranet.de&gt;&gt;%WINDIR%\System32\driv...
6088, 7002, 34595
batch-file, hosts, windows-7
<h1>Windows Batch: How to add Host-Entries?</h1> <p>I want to use this batch script to add new entries into my host file automatically by using <a href="/questions/tagged/windows" class="post-tag" title="show questions tagged &#39;windows&#39;" rel="tag">windows</a> batch.</p> <p>Unfortunately, the script <strong>just...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,204
cmd
# Windows Batch: How to add Host-Entries? I want to use this batch script to add new entries into my host file automatically by using [windows](/questions/tagged/windows "show questions tagged 'windows'") batch. Unfortunately, the script **just adds one single line to the hosts file**, also when i run the script as a...
I would do it this way, so you won't end up with duplicate entries if the script is run multiple times. ``` @echo off SET NEWLINE=^& echo. FIND /C /I "ns1.intranet.de" %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^62.116.159.4 ns1.intranet.de>>%WINDIR%\System32\drivers\etc\hosts FIND /C /...
17584282
How to check if a parameter (or variable) is a number in a Batch script
29
2013-07-11 02:54:58
<p>I need to check if a parameter that is passed to a Windows Batch file is a numeric value or not. It would be good for the check to also works for variables.</p> <p>I found an <a href="https://superuser.com/a/404359">answer</a> to a similar <a href="https://superuser.com/q/404338">question</a>, where the <code>findst...
82,509
393,786
2023-01-19 18:56:02
17,584,764
62
2013-07-11 03:53:33
2,128,947
2013-07-11 03:53:33
https://stackoverflow.com/q/17584282
https://stackoverflow.com/a/17584764
<pre><code>SET "var="&amp;for /f "delims=0123456789" %%i in ("%1") do set var=%%i if defined var (echo %1 NOT numeric) else (echo %1 numeric) </code></pre> <p>Replace <code>%1</code> with <code>%yourvarname%</code> as appropriate</p>
<pre><code>SET "var="&amp;for /f "delims=0123456789" %%i in ("%1") do set var=%%i if defined var (echo %1 NOT numeric) else (echo %1 numeric) </code></pre> <p>Replace <code>%1</code> with <code>%yourvarname%</code> as appropriate</p>
64, 276, 7002
batch-file, variables, windows
<h1>How to check if a parameter (or variable) is a number in a Batch script</h1> <p>I need to check if a parameter that is passed to a Windows Batch file is a numeric value or not. It would be good for the check to also works for variables.</p> <p>I found an <a href="https://superuser.com/a/404359">answer</a> to a simi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,205
cmd
# How to check if a parameter (or variable) is a number in a Batch script I need to check if a parameter that is passed to a Windows Batch file is a numeric value or not. It would be good for the check to also works for variables. I found an [answer](https://superuser.com/a/404359) to a similar [question](https://sup...
``` SET "var="&for /f "delims=0123456789" %%i in ("%1") do set var=%%i if defined var (echo %1 NOT numeric) else (echo %1 numeric) ``` Replace `%1` with `%yourvarname%` as appropriate
15662520
Get last character of a string from a variable
25
2013-03-27 15:20:06
<p>I am having issues with a problem accomplished very easily in most languages but I can't seem to figure it out in batch. I want to extract the last character of a string. In pseudo code..</p> <pre><code>if var1.substring(var1.length, -1) = "0" do something </code></pre> <p>In english...if the last character in ...
77,027
1,788,496
2017-10-05 15:32:17
15,662,605
62
2013-03-27 15:23:39
2,128,947
2013-03-27 16:36:09
https://stackoverflow.com/q/15662520
https://stackoverflow.com/a/15662605
<pre><code>set var=%var:~-1% </code></pre> <p>see <code>SET /?</code> from the prompt for docco.</p> <hr> <pre><code>@ECHO OFF SETLOCAL SET var=abcd SET var2=%var:~-1% CALL :show "-1" SET var2=%var:~-2% CALL :show "-2" SET var2=%var:~-3% CALL :show "-3" SET var2=%var:~1% CALL :show "1" SET var2=%var:~2% CALL :show "...
<pre><code>set var=%var:~-1% </code></pre> <p>see <code>SET /?</code> from the prompt for docco.</p> <hr> <pre><code>@ECHO OFF SETLOCAL SET var=abcd SET var2=%var:~-1% CALL :show "-1" SET var2=%var:~-2% CALL :show "-2" SET var2=%var:~-3% CALL :show "-3" SET var2=%var:~1% CALL :show "1" SET var2=%var:~2% CALL :show "...
4371, 7002
batch-file, substring
<h1>Get last character of a string from a variable</h1> <p>I am having issues with a problem accomplished very easily in most languages but I can't seem to figure it out in batch. I want to extract the last character of a string. In pseudo code..</p> <pre><code>if var1.substring(var1.length, -1) = "0" do something ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,206
cmd
# Get last character of a string from a variable I am having issues with a problem accomplished very easily in most languages but I can't seem to figure it out in batch. I want to extract the last character of a string. In pseudo code.. ``` if var1.substring(var1.length, -1) = "0" do something ``` In english...if ...
``` set var=%var:~-1% ``` see `SET /?` from the prompt for docco. --- ``` @ECHO OFF SETLOCAL SET var=abcd SET var2=%var:~-1% CALL :show "-1" SET var2=%var:~-2% CALL :show "-2" SET var2=%var:~-3% CALL :show "-3" SET var2=%var:~1% CALL :show "1" SET var2=%var:~2% CALL :show "2" SET var2=%var:~3% CALL :show "3" SET var...
298562
Windows XP or later Windows: How can I run a batch file in the background with no window displayed?
136
2008-11-18 12:05:25
<p>I know I have already answered a similar question (<a href="https://stackoverflow.com/questions/289498">Running Batch File in background when windows boots up</a>), but this time I need to launch a batch:</p> <ul> <li>from another batch,</li> <li>without any console window displayed,</li> <li><em>with all arguments...
138,442
6,309
2021-07-04 14:17:11
298,636
61
2008-11-18 12:48:48
36,388
2008-11-18 12:48:48
https://stackoverflow.com/q/298562
https://stackoverflow.com/a/298636
<p>Do you need the second batch file to run asynchronously? Typically one batch file runs another synchronously with the <code>call</code> command, and the second one would share the first one's window.</p> <p>You <strong>can</strong> use <code>start /b</code> <em>second.bat</em> to launch a second batch file <strong...
<p>Do you need the second batch file to run asynchronously? Typically one batch file runs another synchronously with the <code>call</code> command, and the second one would share the first one's window.</p> <p>You <strong>can</strong> use <code>start /b</code> <em>second.bat</em> to launch a second batch file <strong...
64, 2631, 6701, 7002
batch-file, cmd, windows, wsh
<h1>Windows XP or later Windows: How can I run a batch file in the background with no window displayed?</h1> <p>I know I have already answered a similar question (<a href="https://stackoverflow.com/questions/289498">Running Batch File in background when windows boots up</a>), but this time I need to launch a batch:</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,207
cmd
# Windows XP or later Windows: How can I run a batch file in the background with no window displayed? I know I have already answered a similar question ([Running Batch File in background when windows boots up](https://stackoverflow.com/questions/289498)), but this time I need to launch a batch: - from another batch, ...
Do you need the second batch file to run asynchronously? Typically one batch file runs another synchronously with the `call` command, and the second one would share the first one's window. You **can** use `start /b` *second.bat* to launch a second batch file **a**synchronously from your first that shares your first on...
52841620
Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found
96
2018-10-16 18:13:42
<p>I am working on spring batch with spring boot 2.X application, actually its existing code i am checked out from git. While running the application it fails due to below error only for me and same code is working for others.</p> <pre><code>s.c.a.AnnotationConfigApplicationContext : Exception encountered during conte...
462,269
2,726,766
2025-07-29 13:58:56
52,843,150
61
2018-10-16 19:56:24
7,050,229
2018-10-29 14:49:04
https://stackoverflow.com/q/52841620
https://stackoverflow.com/a/52843150
<p>Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail. I would suggest you to define the input file path as property like <code>@Value("${inputFilePath}")</code>. If you need further initialization in your bean define a void method and ann...
<p>Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail. I would suggest you to define the input file path as property like <code>@Value("${inputFilePath}")</code>. If you need further initialization in your bean define a void method and ann...
17, 32978, 41895, 95875
java, spring-annotations, spring-batch, spring-boot
<h1>Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found</h1> <p>I am working on spring batch with spring boot 2.X application, actually its existing code i am checked out from git. While running the application it fails due to below error only for me and same code is working...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,208
cmd
# Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found I am working on spring batch with spring boot 2.X application, actually its existing code i am checked out from git. While running the application it fails due to below error only for me and same code is working for othe...
Since you do not provide the public default constructor and you added your own non-default constructor the instantiation will fail. I would suggest you to define the input file path as property like `@Value("${inputFilePath}")`. If you need further initialization in your bean define a void method and annotate it with `...
138981
How to test if a file is a directory in a batch script?
95
2008-09-26 11:57:24
<p>Is there any way to find out if a file is a directory?</p> <p>I have the file name in a variable. In Perl I can do this:</p> <pre class="lang-dos prettyprint-override"><code>if(-d $var) { print &quot;it's a directory\n&quot; } </code></pre>
159,928
11,234
2024-03-27 14:03:38
138,995
61
2008-09-26 12:01:33
3,171
2016-07-03 18:28:50
https://stackoverflow.com/q/138981
https://stackoverflow.com/a/138995
<p>You can do it like so:</p> <pre><code>IF EXIST %VAR%\NUL ECHO It's a directory </code></pre> <p>However, this only works for directories without spaces in their names. When you add quotes round the variable to handle the spaces it will stop working. To handle directories with spaces, convert the filename to shor...
<p>You can do it like so:</p> <pre><code>IF EXIST %VAR%\NUL ECHO It's a directory </code></pre> <p>However, this only works for directories without spaces in their names. When you add quotes round the variable to handle the spaces it will stop working. To handle directories with spaces, convert the filename to shor...
64, 2631, 7002
batch-file, cmd, windows
<h1>How to test if a file is a directory in a batch script?</h1> <p>Is there any way to find out if a file is a directory?</p> <p>I have the file name in a variable. In Perl I can do this:</p> <pre class="lang-dos prettyprint-override"><code>if(-d $var) { print &quot;it's a directory\n&quot; } </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,209
cmd
# How to test if a file is a directory in a batch script? Is there any way to find out if a file is a directory? I have the file name in a variable. In Perl I can do this: ``` if(-d $var) { print "it's a directory\n" } ```
You can do it like so: ``` IF EXIST %VAR%\NUL ECHO It's a directory ``` However, this only works for directories without spaces in their names. When you add quotes round the variable to handle the spaces it will stop working. To handle directories with spaces, convert the filename to short 8.3 format as follows: ```...
4451668
BAT file to open CMD in current directory
65
2010-12-15 15:32:11
<p>I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the directory they are in. This is tedious (they are in a rather deep file system, so typing out the full path is a pain, copy+paste is better but n...
242,097
192,801
2023-01-13 10:58:13
4,461,768
61
2010-12-16 14:28:05
543,557
2015-10-23 23:01:52
https://stackoverflow.com/q/4451668
https://stackoverflow.com/a/4461768
<p>Create a file named <code>open_dos_here.cmd</code> with the following lines:</p> <pre><code>%~d1 cd "%~p1" call cmd </code></pre> <p>Put this file at any folder. Then, go to your Send To folder (<kbd>Win</kbd>+<kbd>E</kbd>; <kbd>Alt</kbd>+<kbd>D</kbd>;<code>shell:sendto</code>;<kbd>Enter</kbd>). Create a shortcut ...
<p>Create a file named <code>open_dos_here.cmd</code> with the following lines:</p> <pre><code>%~d1 cd "%~p1" call cmd </code></pre> <p>Put this file at any folder. Then, go to your Send To folder (<kbd>Win</kbd>+<kbd>E</kbd>; <kbd>Alt</kbd>+<kbd>D</kbd>;<code>shell:sendto</code>;<kbd>Enter</kbd>). Create a shortcut ...
64, 2216, 2631
cmd, windows, windows-xp
<h1>BAT file to open CMD in current directory</h1> <p>I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the directory they are in. This is tedious (they are in a rather deep file system, so typing out ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,210
cmd
# BAT file to open CMD in current directory I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the directory they are in. This is tedious (they are in a rather deep file system, so typing out the full ...
Create a file named `open_dos_here.cmd` with the following lines: ``` %~d1 cd "%~p1" call cmd ``` Put this file at any folder. Then, go to your Send To folder (`Win`+`E`; `Alt`+`D`;`shell:sendto`;`Enter`). Create a shortcut to point to this open_dos_here.cmd Then, in any folder, select any file or sub-folder. Right-...
27355262
ActiveRecord batch insert (yii2)
37
2014-12-08 09:47:46
<p>Is it possible to insert multiple rows in one query with Yii's ActiveRecord? Or is this only possible via the lower-level DAO objects?</p> <p>I have two models 1- Transaction 2-TransactionItems</p> <p>There are multiple rows(onclick add row) in transaction Items.</p> <p>I want to store multiple rows of transactionit...
53,826
1,561,346
2020-10-27 11:33:47
27,356,763
61
2014-12-08 11:14:28
4,323,648
2015-05-30 12:23:26
https://stackoverflow.com/q/27355262
https://stackoverflow.com/a/27356763
<p>You can use <code>batchInsert()</code> method of <code>yii\db\Command</code>. See details <a href="http://www.yiiframework.com/doc-2.0/yii-db-command.html#batchInsert%28%29-detail" rel="noreferrer">here</a>. When using it with <code>ActiveRecord</code> make sure validate all data before inserting.</p> <p>Assuming y...
<p>You can use <code>batchInsert()</code> method of <code>yii\db\Command</code>. See details <a href="http://www.yiiframework.com/doc-2.0/yii-db-command.html#batchInsert%28%29-detail" rel="noreferrer">here</a>. When using it with <code>ActiveRecord</code> make sure validate all data before inserting.</p> <p>Assuming y...
5, 2429, 58566, 92312
batch-insert, dao, php, yii2
<h1>ActiveRecord batch insert (yii2)</h1> <p>Is it possible to insert multiple rows in one query with Yii's ActiveRecord? Or is this only possible via the lower-level DAO objects?</p> <p>I have two models 1- Transaction 2-TransactionItems</p> <p>There are multiple rows(onclick add row) in transaction Items.</p> <p>I wa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,211
cmd
# ActiveRecord batch insert (yii2) Is it possible to insert multiple rows in one query with Yii's ActiveRecord? Or is this only possible via the lower-level DAO objects? I have two models 1- Transaction 2-TransactionItems There are multiple rows(onclick add row) in transaction Items. I want to store multiple rows o...
You can use `batchInsert()` method of `yii\db\Command`. See details [here](http://www.yiiframework.com/doc-2.0/yii-db-command.html#batchInsert%28%29-detail). When using it with `ActiveRecord` make sure validate all data before inserting. Assuming you have array of $models with class `Post`, it can be done like this: ...
12103028
Sublime Text 2 - Open CMD prompt at current or project directory (Windows)
35
2012-08-24 04:10:41
<p>I have found the following Sublime command to be really useful since it opens an explorer window at the location of the current file:</p> <pre><code>{ "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} }, </code></pre> <p>What I would love is a similar command that w...
50,203
489,586
2019-05-16 11:05:24
12,175,413
61
2012-08-29 10:01:48
872,319
2017-11-13 01:23:52
https://stackoverflow.com/q/12103028
https://stackoverflow.com/a/12175413
<ol> <li>Click the menu <code>preference</code> > <code>Browser Packages</code> in Sublime Text 2.</li> <li>Create a folder <code>Cmd</code> in the directory opened in step 1.</li> <li>Create a python file named <code>cmd.py</code> with the following code in the <code>Cmd</code> folder created in step 2.</li> </ol> <p...
<ol> <li>Click the menu <code>preference</code> > <code>Browser Packages</code> in Sublime Text 2.</li> <li>Create a folder <code>Cmd</code> in the directory opened in step 1.</li> <li>Create a python file named <code>cmd.py</code> with the following code in the <code>Cmd</code> folder created in step 2.</li> </ol> <p...
64, 2631, 78970
cmd, sublimetext2, windows
<h1>Sublime Text 2 - Open CMD prompt at current or project directory (Windows)</h1> <p>I have found the following Sublime command to be really useful since it opens an explorer window at the location of the current file:</p> <pre><code>{ "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "fil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,212
cmd
# Sublime Text 2 - Open CMD prompt at current or project directory (Windows) I have found the following Sublime command to be really useful since it opens an explorer window at the location of the current file: ``` { "keys": ["ctrl+alt+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },...
1. Click the menu `preference` > `Browser Packages` in Sublime Text 2. 2. Create a folder `Cmd` in the directory opened in step 1. 3. Create a python file named `cmd.py` with the following code in the `Cmd` folder created in step 2. ``` import os, sublime_plugin class CmdCommand(sublime_plugin.TextCommand): def ru...
19264972
prevent "abort" in windows batch for npm install
32
2013-10-09 06:46:26
<p>I am writing a bat file to auto install npm packages and install compass. The bat is simple as below:</p> <pre><code>npm install -g bower npm install -g grunt-cli npm install gem update --system --verbose gem install compass --verbose pause </code></pre> <p>I find that after each command, the bat file auto aborts ...
5,677
343,725
2013-10-09 06:54:44
19,265,107
61
2013-10-09 06:54:44
463,115
2013-10-09 06:54:44
https://stackoverflow.com/q/19264972
https://stackoverflow.com/a/19265107
<p>Possibly the npm program is a batch file itself.<br> Then you need to use <code>call</code>, as only then the program control returns to the caller.</p> <pre><code>call npm install -g bower call npm install -g grunt-cli call npm install call gem update --system --verbose call gem install compass --verbose pause </c...
<p>Possibly the npm program is a batch file itself.<br> Then you need to use <code>call</code>, as only then the program control returns to the caller.</p> <pre><code>call npm install -g bower call npm install -g grunt-cli call npm install call gem update --system --verbose call gem install compass --verbose pause </c...
7002, 61387
batch-file, npm
<h1>prevent "abort" in windows batch for npm install</h1> <p>I am writing a bat file to auto install npm packages and install compass. The bat is simple as below:</p> <pre><code>npm install -g bower npm install -g grunt-cli npm install gem update --system --verbose gem install compass --verbose pause </code></pre> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,213
cmd
# prevent "abort" in windows batch for npm install I am writing a bat file to auto install npm packages and install compass. The bat is simple as below: ``` npm install -g bower npm install -g grunt-cli npm install gem update --system --verbose gem install compass --verbose pause ``` I find that after each command, ...
Possibly the npm program is a batch file itself. Then you need to use `call`, as only then the program control returns to the caller. ``` call npm install -g bower call npm install -g grunt-cli call npm install call gem update --system --verbose call gem install compass --verbose pause ```
2572176
How can I make the batch file wait until another batch file completes execution?
31
2010-04-03 18:13:36
<p>How can I make a batch file wait until another batch file has finished?</p> <p>For example, I have:</p> <pre><code>echo hi &gt;r.txt echo some piece of code &gt;&gt;r.txt start ar.bat echo some piece of code &gt;&gt;ar.txt </code></pre> <p>I want the code after <code>start ar.bat</code> to execute only after ...
67,224
71,713
2019-03-18 20:14:18
2,572,178
61
2010-04-03 18:14:26
280,222
2010-04-03 18:14:26
https://stackoverflow.com/q/2572176
https://stackoverflow.com/a/2572178
<p>Use <code>call ar.bat</code> to do it completely with batch file commands.</p> <p>Use <code>start /wait ar.bat</code> to get another window and wait for it to complete.</p>
<p>Use <code>call ar.bat</code> to do it completely with batch file commands.</p> <p>Use <code>start /wait ar.bat</code> to get another window and wait for it to complete.</p>
64, 531, 1231, 7002
batch-file, command-line, scripting, windows
<h1>How can I make the batch file wait until another batch file completes execution?</h1> <p>How can I make a batch file wait until another batch file has finished?</p> <p>For example, I have:</p> <pre><code>echo hi &gt;r.txt echo some piece of code &gt;&gt;r.txt start ar.bat echo some piece of code &gt;&gt;ar.txt...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,214
cmd
# How can I make the batch file wait until another batch file completes execution? How can I make a batch file wait until another batch file has finished? For example, I have: ``` echo hi >r.txt echo some piece of code >>r.txt start ar.bat echo some piece of code >>ar.txt ``` I want the code after `start ar.bat`...
Use `call ar.bat` to do it completely with batch file commands. Use `start /wait ar.bat` to get another window and wait for it to complete.
5615206
windows batch files: setting variable in for loop
30
2011-04-10 22:41:44
<p>I have a number of files with the same naming scheme. As a sample, four files are called "num_001_001.txt", "num_002_001.txt", "num_002_002.txt", "num_002_003.txt"</p> <p>The first set of numbers represents which "package" it's from, and the second set of numbers is simply used to distinguish them from one another....
97,449
536,607
2013-10-21 16:28:51
5,615,355
61
2011-04-10 23:12:38
9,536
2011-04-10 23:12:38
https://stackoverflow.com/q/5615206
https://stackoverflow.com/a/5615355
<p>Your problem is that the variable get replaced when the batch processor reads the for command, before it is executed.</p> <p>Try this:</p> <pre><code>SET temp=Hello, world! CALL yourbatchfile.bat </code></pre> <p>And you'll see Hello printed 5 times.</p> <p>The solution is delayed expansion; you need to first en...
<p>Your problem is that the variable get replaced when the batch processor reads the for command, before it is executed.</p> <p>Try this:</p> <pre><code>SET temp=Hello, world! CALL yourbatchfile.bat </code></pre> <p>And you'll see Hello printed 5 times.</p> <p>The solution is delayed expansion; you need to first en...
7002, 28223
batch-file, windows-vista
<h1>windows batch files: setting variable in for loop</h1> <p>I have a number of files with the same naming scheme. As a sample, four files are called "num_001_001.txt", "num_002_001.txt", "num_002_002.txt", "num_002_003.txt"</p> <p>The first set of numbers represents which "package" it's from, and the second set of n...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,215
cmd
# windows batch files: setting variable in for loop I have a number of files with the same naming scheme. As a sample, four files are called "num_001_001.txt", "num_002_001.txt", "num_002_002.txt", "num_002_003.txt" The first set of numbers represents which "package" it's from, and the second set of numbers is simply...
Your problem is that the variable get replaced when the batch processor reads the for command, before it is executed. Try this: ``` SET temp=Hello, world! CALL yourbatchfile.bat ``` And you'll see Hello printed 5 times. The solution is delayed expansion; you need to first enable it, and then use `!temp!` instead of...
9472804
Batch-file for mysqldump to backup each database into a separate file
20
2012-02-27 21:46:28
<p>Trying to create a batch (cmd) file for backing up each database into a separate file. Databases are created/deleted often, so batch file needs to grab current db names everytime it runs and backup each one of them.</p> <p>Here is how I want it to be:</p> <pre><code>mysql -e "show databases" -u root --password=123...
59,835
1,017,550
2018-05-25 15:05:08
9,749,003
61
2012-03-17 09:57:42
68,998
2014-11-14 22:38:41
https://stackoverflow.com/q/9472804
https://stackoverflow.com/a/9749003
<p>This can be run directly in cmd (I wrapped the line but it should not be wrapped):</p> <pre><code>mysql.exe -uroot -p1234 -s -N -e "SHOW DATABASES" | for /F "usebackq" %D in (`findstr /V "information_schema performance_schema"`) do mysqldump %D -uroot -p1234 &gt; S:\Backup\MySQL\%D.sql </code></pre> <p>In a ...
<p>This can be run directly in cmd (I wrapped the line but it should not be wrapped):</p> <pre><code>mysql.exe -uroot -p1234 -s -N -e "SHOW DATABASES" | for /F "usebackq" %D in (`findstr /V "information_schema performance_schema"`) do mysqldump %D -uroot -p1234 &gt; S:\Backup\MySQL\%D.sql </code></pre> <p>In a ...
21, 64, 7002, 31985
batch-file, mysql, windows, windows-server-2008
<h1>Batch-file for mysqldump to backup each database into a separate file</h1> <p>Trying to create a batch (cmd) file for backing up each database into a separate file. Databases are created/deleted often, so batch file needs to grab current db names everytime it runs and backup each one of them.</p> <p>Here is how I ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,216
cmd
# Batch-file for mysqldump to backup each database into a separate file Trying to create a batch (cmd) file for backing up each database into a separate file. Databases are created/deleted often, so batch file needs to grab current db names everytime it runs and backup each one of them. Here is how I want it to be: ...
This can be run directly in cmd (I wrapped the line but it should not be wrapped): ``` mysql.exe -uroot -p1234 -s -N -e "SHOW DATABASES" | for /F "usebackq" %D in (`findstr /V "information_schema performance_schema"`) do mysqldump %D -uroot -p1234 > S:\Backup\MySQL\%D.sql ``` In a batch file you will need to es...
130112
Command line .cmd/.bat script, how to get directory of running script
87
2008-09-24 21:32:26
<p>How can you get the directory of the script that was run and use it within the .cmd file?</p>
121,091
3,153
2022-07-01 17:42:07
130,118
60
2008-09-24 21:34:20
419
2019-05-29 11:43:30
https://stackoverflow.com/q/130112
https://stackoverflow.com/a/130118
<p>Raymond Chen has a few ideas:</p> <blockquote> <p><a href="https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573" rel="nofollow noreferrer">https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573</a></p> </blockquote> <p>Quoted here in full because MSDN archives tend to be somewhat unreliable:<...
<p>Raymond Chen has a few ideas:</p> <blockquote> <p><a href="https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573" rel="nofollow noreferrer">https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573</a></p> </blockquote> <p>Quoted here in full because MSDN archives tend to be somewhat unreliable:<...
7002
batch-file
<h1>Command line .cmd/.bat script, how to get directory of running script</h1> <p>How can you get the directory of the script that was run and use it within the .cmd file?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,217
cmd
# Command line .cmd/.bat script, how to get directory of running script How can you get the directory of the script that was run and use it within the .cmd file?
Raymond Chen has a few ideas: > <https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573> Quoted here in full because MSDN archives tend to be somewhat unreliable: > The easy way is to use the `%CD%` pseudo-variable. It expands to the > current working directory. > > `set OLDDIR=%CD%` > `.. do stuff ..` ...
31574365
Best practice for exiting batch file?
43
2015-07-22 21:32:08
<p>For a batch file I want to check for different conditions and have a help message</p> <p>Which one is the best practice for exiting the batch file after displaying the message? </p> <pre><code>if "%1"=="/?"( echo "help message" exit /b 0 ) [more code] </code></pre> <p>or</p> <pre><code>if "%1"=="/?"( echo ...
157,412
4,024,635
2015-07-22 23:05:07
31,575,441
60
2015-07-22 22:58:03
5,056,380
2015-07-22 23:05:07
https://stackoverflow.com/q/31574365
https://stackoverflow.com/a/31575441
<p>Personally I use <code>exit</code>.</p> <blockquote> <ul> <li><p>The normal <code>exit</code> command simply terminates the current script, and the parent (for example if you were running a script from command line, or calling it from another batch file)</p> </li> <li><p><code>exit /b</code> is used to terminate the...
<p>Personally I use <code>exit</code>.</p> <blockquote> <ul> <li><p>The normal <code>exit</code> command simply terminates the current script, and the parent (for example if you were running a script from command line, or calling it from another batch file)</p> </li> <li><p><code>exit /b</code> is used to terminate the...
64, 531, 7002
batch-file, scripting, windows
<h1>Best practice for exiting batch file?</h1> <p>For a batch file I want to check for different conditions and have a help message</p> <p>Which one is the best practice for exiting the batch file after displaying the message? </p> <pre><code>if "%1"=="/?"( echo "help message" exit /b 0 ) [more code] </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,218
cmd
# Best practice for exiting batch file? For a batch file I want to check for different conditions and have a help message Which one is the best practice for exiting the batch file after displaying the message? ``` if "%1"=="/?"( echo "help message" exit /b 0 ) [more code] ``` or ``` if "%1"=="/?"( echo "help...
Personally I use `exit`. > - The normal `exit` command simply terminates the current script, and the parent (for example if you were running a script from command line, or calling it from another batch file) > - `exit /b` is used to terminate the current script, but leaves the parent window/script/calling label open. ...
29655065
Check if Windows batch variable starts with a specific string
41
2015-04-15 15:55:08
<p>How can I find out (with Windows a batch command), if, for example, a variable starts with <code>ABC</code>?</p> <p>I know that I can search for variables if I know the whole content (<code>if &quot;%variable%&quot;==&quot;abc&quot;</code>), but I want that it only looks after the beginning.</p> <p>I also need it to...
43,909
null
2020-07-31 21:38:11
29,655,184
60
2015-04-15 16:00:31
696,808
2019-06-10 13:47:20
https://stackoverflow.com/q/29655065
https://stackoverflow.com/a/29655184
<p>Use the <a href="http://ss64.com/nt/syntax-substring.html" rel="noreferrer">variable substring syntax</a>:</p> <pre><code>IF "%variable:~0,3%"=="ABC" [...] </code></pre> <p>If you need the path to the batch file without the batch file name, you can use the variable:</p> <pre><code>%~dp0 </code></pre> <p>Syntax f...
<p>Use the <a href="http://ss64.com/nt/syntax-substring.html" rel="noreferrer">variable substring syntax</a>:</p> <pre><code>IF "%variable:~0,3%"=="ABC" [...] </code></pre> <p>If you need the path to the batch file without the batch file name, you can use the variable:</p> <pre><code>%~dp0 </code></pre> <p>Syntax f...
276, 2773, 7002
batch-file, if-statement, variables
<h1>Check if Windows batch variable starts with a specific string</h1> <p>How can I find out (with Windows a batch command), if, for example, a variable starts with <code>ABC</code>?</p> <p>I know that I can search for variables if I know the whole content (<code>if &quot;%variable%&quot;==&quot;abc&quot;</code>), but ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,219
cmd
# Check if Windows batch variable starts with a specific string How can I find out (with Windows a batch command), if, for example, a variable starts with `ABC`? I know that I can search for variables if I know the whole content (`if "%variable%"=="abc"`), but I want that it only looks after the beginning. I also ne...
Use the [variable substring syntax](http://ss64.com/nt/syntax-substring.html): ``` IF "%variable:~0,3%"=="ABC" [...] ``` If you need the path to the batch file without the batch file name, you can use the variable: ``` %~dp0 ``` Syntax for this is explained in the [help for the `for` command](https://stackoverflow....
24429976
pass parameter from jenkins parameterized build to windows batch command
21
2014-06-26 12:00:33
<p>I am starting to use Jenkins, which is a really great tool. We are using parameterized build, we define parameter such as branch name ${Branch} (e.g. dev, release, main etc).</p> <p>In the build config, I can add a windows batch command, is there a way I can pass down these parameters to the batch command?</p> <p>...
55,673
1,223,876
2021-01-02 19:32:31
24,436,799
60
2014-06-26 17:31:01
1,720,943
2015-08-11 11:33:04
https://stackoverflow.com/q/24429976
https://stackoverflow.com/a/24436799
<p>Using <strong>Parameterized Build</strong>, you need to define parameters. The value of these will be prompted to you when you click "Build" link.</p> <p>The name of the parameters should be a <strong>plain name</strong>, preferably without spaces, like <code>Branch</code>. Do not add any <code>${}</code> or <code>...
<p>Using <strong>Parameterized Build</strong>, you need to define parameters. The value of these will be prompted to you when you click "Build" link.</p> <p>The name of the parameters should be a <strong>plain name</strong>, preferably without spaces, like <code>Branch</code>. Do not add any <code>${}</code> or <code>...
2631, 7002, 64999
batch-file, cmd, jenkins
<h1>pass parameter from jenkins parameterized build to windows batch command</h1> <p>I am starting to use Jenkins, which is a really great tool. We are using parameterized build, we define parameter such as branch name ${Branch} (e.g. dev, release, main etc).</p> <p>In the build config, I can add a windows batch comma...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,221
cmd
# pass parameter from jenkins parameterized build to windows batch command I am starting to use Jenkins, which is a really great tool. We are using parameterized build, we define parameter such as branch name ${Branch} (e.g. dev, release, main etc). In the build config, I can add a windows batch command, is there a w...
Using **Parameterized Build**, you need to define parameters. The value of these will be prompted to you when you click "Build" link. The name of the parameters should be a **plain name**, preferably without spaces, like `Branch`. Do not add any `${}` or `%%` to definition of the parameter name. In the **build steps*...
6836566
Delete all files and folders in a directory
174
2011-07-26 21:01:45
<p>I want to have a batch file that will delete all the folders and files in my cache folder for my wireless toolkit.</p> <p>Currently I have the following:</p> <pre><code>cd "C:\Users\tbrollo\j2mewtk\2.5.2\appdb\RMS" del *.db </code></pre> <p>This will delete all .db files in my <em>RMS</em> directory, however I wa...
567,996
69,514
2025-11-18 08:43:26
6,836,600
59
2011-07-26 21:04:35
846,471
2014-05-23 12:51:15
https://stackoverflow.com/q/6836566
https://stackoverflow.com/a/6836600
<p><code>del *.*</code> instead of <code>del *.db</code>. That will remove everything.</p>
<p><code>del *.*</code> instead of <code>del *.db</code>. That will remove everything.</p>
64, 2631, 7002
batch-file, cmd, windows
<h1>Delete all files and folders in a directory</h1> <p>I want to have a batch file that will delete all the folders and files in my cache folder for my wireless toolkit.</p> <p>Currently I have the following:</p> <pre><code>cd "C:\Users\tbrollo\j2mewtk\2.5.2\appdb\RMS" del *.db </code></pre> <p>This will delete all...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,222
cmd
# Delete all files and folders in a directory I want to have a batch file that will delete all the folders and files in my cache folder for my wireless toolkit. Currently I have the following: ``` cd "C:\Users\tbrollo\j2mewtk\2.5.2\appdb\RMS" del *.db ``` This will delete all .db files in my *RMS* directory, howeve...
`del *.*` instead of `del *.db`. That will remove everything.
804646
How do you strip quotes out of an ECHO'ed string in a Windows batch file?
58
2009-04-29 22:56:41
<p>I have a Windows batch file I'm creating, but I have to ECHO a large complex string, so I'm having to put double quotes on either end. The problem is that the quotes are also being ECHOed to the file I'm writing it to. How do you ECHO a string like that and strip the quotes off?</p> <p><strong>UPDATE:</strong></p...
92,124
13,295
2024-04-22 13:54:04
804,782
59
2009-04-29 23:36:25
24,355
2009-04-30 00:01:18
https://stackoverflow.com/q/804646
https://stackoverflow.com/a/804782
<p>The call command has this functionality built in. To quote the help for call:</p> <pre><code> Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax: %~1 - expands %1 removing any surrounding quotes (") </code></pre> <p>Here is a primitive example:</p> <...
<p>The call command has this functionality built in. To quote the help for call:</p> <pre><code> Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax: %~1 - expands %1 removing any surrounding quotes (") </code></pre> <p>Here is a primitive example:</p> <...
64, 430, 5282, 7002, 13824
batch-file, echo, quotes, sed, windows
<h1>How do you strip quotes out of an ECHO'ed string in a Windows batch file?</h1> <p>I have a Windows batch file I'm creating, but I have to ECHO a large complex string, so I'm having to put double quotes on either end. The problem is that the quotes are also being ECHOed to the file I'm writing it to. How do you EC...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,223
cmd
# How do you strip quotes out of an ECHO'ed string in a Windows batch file? I have a Windows batch file I'm creating, but I have to ECHO a large complex string, so I'm having to put double quotes on either end. The problem is that the quotes are also being ECHOed to the file I'm writing it to. How do you ECHO a string...
The call command has this functionality built in. To quote the help for call: ``` Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax: %~1 - expands %1 removing any surrounding quotes (") ``` Here is a primitive example: ``` @echo off setlocal set mystr...
577467
How to pause a script when it ends on Windows?
57
2009-02-23 12:20:26
<p>I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.</p> <p>After the script has been processed, the interpreter terminates and the output window is closed which makes it impossible to read script output.</p> ...
133,893
null
2022-03-02 16:19:52
577,488
59
2009-02-23 12:30:06
64,697
2011-09-02 16:41:25
https://stackoverflow.com/q/577467
https://stackoverflow.com/a/577488
<p>One way is to leave a <code>raw_input()</code> at the end so the script waits for you to press Enter before it terminates.</p>
<p>One way is to leave a <code>raw_input()</code> at the end so the script waits for you to press Enter before it terminates.</p>
16, 64, 1231, 2631
cmd, command-line, python, windows
<h1>How to pause a script when it ends on Windows?</h1> <p>I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.</p> <p>After the script has been processed, the interpreter terminates and the output window is clos...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,224
cmd
# How to pause a script when it ends on Windows? I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter. After the script has been processed, the interpreter terminates and the output window is closed which makes ...
One way is to leave a `raw_input()` at the end so the script waits for you to press Enter before it terminates.
835941
How do you run a .bat file from PHP?
48
2009-05-07 17:17:00
<p>Can anyone tell me how to execute a .bat file from a PHP script?</p> <p>I have tried:</p> <pre><code>exec("C:\[path to file]"); system("C:\[path to file]"); </code></pre> <p>Nothing is working. I've checked the PHP manuals and googled around but can't find a good answer. Anyone know where I'm going wrong? </p> <...
150,358
77,174
2020-10-08 10:22:53
835,955
59
2009-05-07 17:20:09
21,886
2009-05-07 17:20:09
https://stackoverflow.com/q/835941
https://stackoverflow.com/a/835955
<p>You might need to run it via <code>cmd</code>, eg:</p> <pre><code>system("cmd /c C:[path to file]"); </code></pre>
<p>You might need to run it via <code>cmd</code>, eg:</p> <pre><code>system("cmd /c C:[path to file]"); </code></pre>
5, 5163, 7002, 7932
batch-file, exec, php, system
<h1>How do you run a .bat file from PHP?</h1> <p>Can anyone tell me how to execute a .bat file from a PHP script?</p> <p>I have tried:</p> <pre><code>exec("C:\[path to file]"); system("C:\[path to file]"); </code></pre> <p>Nothing is working. I've checked the PHP manuals and googled around but can't find a good answ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,225
cmd
# How do you run a .bat file from PHP? Can anyone tell me how to execute a .bat file from a PHP script? I have tried: ``` exec("C:\[path to file]"); system("C:\[path to file]"); ``` Nothing is working. I've checked the PHP manuals and googled around but can't find a good answer. Anyone know where I'm going wrong? ...
You might need to run it via `cmd`, eg: ``` system("cmd /c C:[path to file]"); ```
40610241
Automatically answer to input prompt in windows batch
45
2016-11-15 12:48:40
<p>In a windows batch, I want to start a program that prompts the user for an input:</p> <pre><code>&gt;someProgram.exe &gt; "Please enter "s" to start the program: &gt; </code></pre> <p>How can I automatically pass the "y" input to the prompt, such that I can start the program by just clicking the batch? </p>
102,312
1,934,212
2024-09-09 15:48:09
40,610,377
59
2016-11-15 12:55:48
1,151,769
2016-11-15 13:01:24
https://stackoverflow.com/q/40610241
https://stackoverflow.com/a/40610377
<p>You want this:</p> <pre><code>echo y | [Command] </code></pre> <p>Eg: echo y | program.exe</p> <pre><code>"echo &lt;answer&gt; | &lt;batch command&gt;" </code></pre> <p>Ex: The del /P command option will prompt for user's confirmation before deleting the file. So if you are using this option in your batch script...
<p>You want this:</p> <pre><code>echo y | [Command] </code></pre> <p>Eg: echo y | program.exe</p> <pre><code>"echo &lt;answer&gt; | &lt;batch command&gt;" </code></pre> <p>Ex: The del /P command option will prompt for user's confirmation before deleting the file. So if you are using this option in your batch script...
64, 7002
batch-file, windows
<h1>Automatically answer to input prompt in windows batch</h1> <p>In a windows batch, I want to start a program that prompts the user for an input:</p> <pre><code>&gt;someProgram.exe &gt; "Please enter "s" to start the program: &gt; </code></pre> <p>How can I automatically pass the "y" input to the prompt, such that...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,226
cmd
# Automatically answer to input prompt in windows batch In a windows batch, I want to start a program that prompts the user for an input: ``` >someProgram.exe > "Please enter "s" to start the program: > ``` How can I automatically pass the "y" input to the prompt, such that I can start the program by just clicking t...
You want this: ``` echo y | [Command] ``` Eg: echo y | program.exe ``` "echo <answer> | <batch command>" ``` Ex: The del /P command option will prompt for user's confirmation before deleting the file. So if you are using this option in your batch script, it requires manual input to proceed further. To avoid this ma...
7402587
Run command2 only if command1 succeeded in cmd windows shell
33
2011-09-13 13:21:40
<p>How do we combine commands in cmd shell language such that the second command is only executed if the first command successfully completed?</p> <p>something like following bash-command</p> <pre><code>make &amp;&amp; ./a.out </code></pre> <p><code>a.out</code> is only executed if <code>make</code> was successful</...
40,030
674,669
2020-08-10 14:23:16
7,402,638
59
2011-09-13 13:25:25
276,052
2011-09-13 13:25:25
https://stackoverflow.com/q/7402587
https://stackoverflow.com/a/7402638
<p>The following</p> <pre><code>command1 &amp;&amp; command2 </code></pre> <p>should work on <code>cmd</code> as well. Quote from <a href="http://htipe.wordpress.com/2009/07/19/multiple-commands-on-a-single-windows-command-line/" rel="noreferrer">here</a>:</p> <blockquote> <p><em>When using cmd.exe, you can put mu...
<p>The following</p> <pre><code>command1 &amp;&amp; command2 </code></pre> <p>should work on <code>cmd</code> as well. Quote from <a href="http://htipe.wordpress.com/2009/07/19/multiple-commands-on-a-single-windows-command-line/" rel="noreferrer">here</a>:</p> <blockquote> <p><em>When using cmd.exe, you can put mu...
2631, 9938
cmd, command-prompt
<h1>Run command2 only if command1 succeeded in cmd windows shell</h1> <p>How do we combine commands in cmd shell language such that the second command is only executed if the first command successfully completed?</p> <p>something like following bash-command</p> <pre><code>make &amp;&amp; ./a.out </code></pre> <p><co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,228
cmd
# Run command2 only if command1 succeeded in cmd windows shell How do we combine commands in cmd shell language such that the second command is only executed if the first command successfully completed? something like following bash-command ``` make && ./a.out ``` `a.out` is only executed if `make` was successful
The following ``` command1 && command2 ``` should work on `cmd` as well. Quote from [here](http://htipe.wordpress.com/2009/07/19/multiple-commands-on-a-single-windows-command-line/): > *When using cmd.exe, you can put multiple commands on the same line by using ‘&’ or ‘&&’ between commands. Using a single ampersand ...
6812484
batch file test error level
30
2011-07-25 06:32:26
<p>I'm trying to conditionally run an exe from a batch file conditionally upon another exe executing successfully.</p> <p>I've tried a few different combinations of IF and ERRORLEVEL but none seem to work</p> <pre><code>"..\..\..\TeamBuildTypes\Current Branch\DatabaseUpdate.exe" -s localhost\sql2008r2 IF %ERRORLEVE...
118,769
351,614
2021-09-13 21:00:43
6,817,833
59
2011-07-25 14:40:47
3,501
2017-10-06 16:05:33
https://stackoverflow.com/q/6812484
https://stackoverflow.com/a/6817833
<p><code>IF ERRORLEVEL ...</code> is a special syntax supported since the DOS days, the <code>%ERRORLEVEL%</code> variable support was added in WinNT.</p> <p>The original syntax is used like this:</p> <pre><code>call someapp.exe if errorlevel 1 goto handleerror1orhigher echo succuess... </code></pre> <p>To use the ...
<p><code>IF ERRORLEVEL ...</code> is a special syntax supported since the DOS days, the <code>%ERRORLEVEL%</code> variable support was added in WinNT.</p> <p>The original syntax is used like this:</p> <pre><code>call someapp.exe if errorlevel 1 goto handleerror1orhigher echo succuess... </code></pre> <p>To use the ...
379, 7002
batch-file, error-handling
<h1>batch file test error level</h1> <p>I'm trying to conditionally run an exe from a batch file conditionally upon another exe executing successfully.</p> <p>I've tried a few different combinations of IF and ERRORLEVEL but none seem to work</p> <pre><code>"..\..\..\TeamBuildTypes\Current Branch\DatabaseUpdate.exe" -...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,229
cmd
# batch file test error level I'm trying to conditionally run an exe from a batch file conditionally upon another exe executing successfully. I've tried a few different combinations of IF and ERRORLEVEL but none seem to work ``` "..\..\..\TeamBuildTypes\Current Branch\DatabaseUpdate.exe" -s localhost\sql2008r2 IF ...
`IF ERRORLEVEL ...` is a special syntax supported since the DOS days, the `%ERRORLEVEL%` variable support was added in WinNT. The original syntax is used like this: ``` call someapp.exe if errorlevel 1 goto handleerror1orhigher echo succuess... ``` To use the variable, use the normal IF syntax: `if %errorlevel%==0 e...
48001759
What is right batch normalization function in Tensorflow?
23
2017-12-28 04:56:56
<p>In tensorflow 1.4, I found two functions that do batch normalization and they look same:</p> <ol> <li><code>tf.layers.batch_normalization</code> (<a href="https://www.tensorflow.org/api_docs/python/tf/layers/batch_normalization" rel="noreferrer">link</a>)</li> <li><code>tf.contrib.layers.batch_norm</code> (<a href=...
18,749
6,279,632
2017-12-28 12:13:01
48,006,315
59
2017-12-28 11:04:07
712,995
2017-12-28 11:04:07
https://stackoverflow.com/q/48001759
https://stackoverflow.com/a/48006315
<p>Just to add to the list, there're several more ways to do batch-norm in tensorflow:</p> <ul> <li><a href="https://www.tensorflow.org/api_docs/python/tf/nn/batch_normalization" rel="noreferrer"><code>tf.nn.batch_normalization</code></a> is a low-level op. The caller is responsible to handle <code>mean</code> and <co...
<p>Just to add to the list, there're several more ways to do batch-norm in tensorflow:</p> <ul> <li><a href="https://www.tensorflow.org/api_docs/python/tf/nn/batch_normalization" rel="noreferrer"><code>tf.nn.batch_normalization</code></a> is a low-level op. The caller is responsible to handle <code>mean</code> and <co...
16, 40102, 100570, 115813, 124994
batch-normalization, deep-learning, neural-network, python, tensorflow
<h1>What is right batch normalization function in Tensorflow?</h1> <p>In tensorflow 1.4, I found two functions that do batch normalization and they look same:</p> <ol> <li><code>tf.layers.batch_normalization</code> (<a href="https://www.tensorflow.org/api_docs/python/tf/layers/batch_normalization" rel="noreferrer">lin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,231
cmd
# What is right batch normalization function in Tensorflow? In tensorflow 1.4, I found two functions that do batch normalization and they look same: 1. `tf.layers.batch_normalization` ([link](https://www.tensorflow.org/api_docs/python/tf/layers/batch_normalization)) 2. `tf.contrib.layers.batch_norm` ([link](https://w...
Just to add to the list, there're several more ways to do batch-norm in tensorflow: - [`tf.nn.batch_normalization`](https://www.tensorflow.org/api_docs/python/tf/nn/batch_normalization) is a low-level op. The caller is responsible to handle `mean` and `variance` tensors themselves. - [`tf.nn.fused_batch_norm`](https:/...
14952295
Set output of a command as a variable (with pipes)
67
2013-02-19 07:43:52
<p>Can you redirect the output of a command to a variable with pipes?</p> <p>I haven't tried much as I haven't been able to think of anything to try, but I have tried one method (with two variations)...</p> <p>For example:</p> <pre><code>echo Hello|set text= </code></pre> <p>Didn't work, neither did:</p> <pre><cod...
231,630
2,045,818
2024-03-18 00:36:45
14,965,458
58
2013-02-19 19:09:15
463,115
2024-03-18 00:36:45
https://stackoverflow.com/q/14952295
https://stackoverflow.com/a/14965458
<p>Your way can't work for two reasons.</p> <p>You need to use <code>set /p text=</code> for setting the variable with <em>user input</em>.<br /> The other problem is the pipe.<br /> A pipe starts two asynchronous cmd.exe instances and after finishing the job both instances are closed.</p> <p>That's the cause why it se...
<p>Your way can't work for two reasons.</p> <p>You need to use <code>set /p text=</code> for setting the variable with <em>user input</em>.<br /> The other problem is the pipe.<br /> A pipe starts two asynchronous cmd.exe instances and after finishing the job both instances are closed.</p> <p>That's the cause why it se...
7002
batch-file
<h1>Set output of a command as a variable (with pipes)</h1> <p>Can you redirect the output of a command to a variable with pipes?</p> <p>I haven't tried much as I haven't been able to think of anything to try, but I have tried one method (with two variations)...</p> <p>For example:</p> <pre><code>echo Hello|set text...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,232
cmd
# Set output of a command as a variable (with pipes) Can you redirect the output of a command to a variable with pipes? I haven't tried much as I haven't been able to think of anything to try, but I have tried one method (with two variations)... For example: ``` echo Hello|set text= ``` Didn't work, neither did: ...
Your way can't work for two reasons. You need to use `set /p text=` for setting the variable with *user input*. The other problem is the pipe. A pipe starts two asynchronous cmd.exe instances and after finishing the job both instances are closed. That's the cause why it seems that the variables are not set, but a...
998366
How to store the hostname in a variable in a .bat file?
61
2009-06-15 21:00:53
<p>I would like to convert this <code>/bin/sh</code> syntax into a widely compatible Windows batch script:</p> <pre><code>host=`hostname` echo ${host} </code></pre> <p>How to do this so that it'll work on any Windows Vista, Windows XP, and Windows 2000 machine?</p> <p>To clarify: I would then like to go on in the pr...
259,330
87,408
2020-02-24 08:20:01
998,596
58
2009-06-15 21:53:38
3,171
2009-06-15 21:53:38
https://stackoverflow.com/q/998366
https://stackoverflow.com/a/998596
<p>I usually read command output in to variables using the <code>FOR</code> command as it saves having to create temporary files. For example:</p> <pre><code>FOR /F "usebackq" %i IN (`hostname`) DO SET MYVAR=%i </code></pre> <p>Note, the above statement will work on the command line but not in a batch file. To use ...
<p>I usually read command output in to variables using the <code>FOR</code> command as it saves having to create temporary files. For example:</p> <pre><code>FOR /F "usebackq" %i IN (`hostname`) DO SET MYVAR=%i </code></pre> <p>Note, the above statement will work on the command line but not in a batch file. To use ...
64, 531, 7002, 7760
batch-file, hostname, scripting, windows
<h1>How to store the hostname in a variable in a .bat file?</h1> <p>I would like to convert this <code>/bin/sh</code> syntax into a widely compatible Windows batch script:</p> <pre><code>host=`hostname` echo ${host} </code></pre> <p>How to do this so that it'll work on any Windows Vista, Windows XP, and Windows 2000 ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,233
cmd
# How to store the hostname in a variable in a .bat file? I would like to convert this `/bin/sh` syntax into a widely compatible Windows batch script: ``` host=`hostname` echo ${host} ``` How to do this so that it'll work on any Windows Vista, Windows XP, and Windows 2000 machine? To clarify: I would then like to g...
I usually read command output in to variables using the `FOR` command as it saves having to create temporary files. For example: ``` FOR /F "usebackq" %i IN (`hostname`) DO SET MYVAR=%i ``` Note, the above statement will work on the command line but not in a batch file. To use it in batch file escape the `%` in the `...
26993101
Switching between different JDK versions in Windows
48
2014-11-18 11:22:49
<p>I'm working on few projects and some of them are using different JDK. Switching between JDK versions is not comfortable. So I was wondering if there is any easy way to change it?</p> <p>I found 2 ways, which should solve this problem, but it doesn't work.</p> <p>First solution is creating a bat files like this:</p...
166,612
3,474,610
2025-02-26 20:55:04
26,993,233
58
2014-11-18 11:29:10
897,024
2025-02-26 20:55:04
https://stackoverflow.com/q/26993101
https://stackoverflow.com/a/26993233
<p>The <code>set</code> command only works for the current terminal. To permanently set a system or user environment variable you can use <a href="http://technet.microsoft.com/en-us/library/cc755104.aspx" rel="nofollow noreferrer"><code>setx</code></a>.</p> <p>You can set the variable for the current user like this:</p...
<p>The <code>set</code> command only works for the current terminal. To permanently set a system or user environment variable you can use <a href="http://technet.microsoft.com/en-us/library/cc755104.aspx" rel="nofollow noreferrer"><code>setx</code></a>.</p> <p>You can set the variable for the current user like this:</p...
17, 64, 2631, 9013
cmd, environment-variables, java, windows
<h1>Switching between different JDK versions in Windows</h1> <p>I'm working on few projects and some of them are using different JDK. Switching between JDK versions is not comfortable. So I was wondering if there is any easy way to change it?</p> <p>I found 2 ways, which should solve this problem, but it doesn't work....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,234
cmd
# Switching between different JDK versions in Windows I'm working on few projects and some of them are using different JDK. Switching between JDK versions is not comfortable. So I was wondering if there is any easy way to change it? I found 2 ways, which should solve this problem, but it doesn't work. First solution...
The `set` command only works for the current terminal. To permanently set a system or user environment variable you can use [`setx`](http://technet.microsoft.com/en-us/library/cc755104.aspx). You can set the variable for the current user like this: ``` setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_72" ``` You can a...
24173825
What does single-quoting do in Windows batch files?
44
2014-06-11 22:42:52
<p>I recently ran a command in windows cmd with single quotes in it and found that it did not behave as I expected.</p> <p>From trying to google "windows batch single quote vs double quote" I've found a few articles where people asked about having windows treat single quotes like double quotes, and about how bash trea...
29,024
956,134
2020-08-28 02:01:28
24,181,667
58
2014-06-12 10:03:43
1,012,053
2014-07-03 11:56:33
https://stackoverflow.com/q/24173825
https://stackoverflow.com/a/24181667
<p>Single quotes are not used at all by the cmd.exe command processor except to enclose the command to run within a FOR /F statement:</p> <pre><code>for /f %%A in ('someCommand') do ... </code></pre> <p>Or to specify a string to process by FOR /F if the USEBACKQ option is used:</p> <pre><code>for /f "usebackq" %%A i...
<p>Single quotes are not used at all by the cmd.exe command processor except to enclose the command to run within a FOR /F statement:</p> <pre><code>for /f %%A in ('someCommand') do ... </code></pre> <p>Or to specify a string to process by FOR /F if the USEBACKQ option is used:</p> <pre><code>for /f "usebackq" %%A i...
430, 2631, 7002
batch-file, cmd, quotes
<h1>What does single-quoting do in Windows batch files?</h1> <p>I recently ran a command in windows cmd with single quotes in it and found that it did not behave as I expected.</p> <p>From trying to google "windows batch single quote vs double quote" I've found a few articles where people asked about having windows tr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,235
cmd
# What does single-quoting do in Windows batch files? I recently ran a command in windows cmd with single quotes in it and found that it did not behave as I expected. From trying to google "windows batch single quote vs double quote" I've found a few articles where people asked about having windows treat single quote...
Single quotes are not used at all by the cmd.exe command processor except to enclose the command to run within a FOR /F statement: ``` for /f %%A in ('someCommand') do ... ``` Or to specify a string to process by FOR /F if the USEBACKQ option is used: ``` for /f "usebackq" %%A in ('some string') do ... ``` All othe...
22093508
Add password to keytool command
42
2014-02-28 11:11:18
<p>I've made a .bat file to get the SHA1 of my Android app so I don't need to type the command each time</p> <p><code>keytool -list -v -keystore "Path/To/My/Key.jks"</code></p> <p>When I run the bat file I get asked for the password. Is it possible to either put the password in the command e.g. something like <code>-...
97,434
993,600
2021-10-13 14:20:11
23,425,423
58
2014-05-02 09:59:37
991,432
2014-05-02 09:59:37
https://stackoverflow.com/q/22093508
https://stackoverflow.com/a/23425423
<p>The <code>keytool</code> that ships with the Oracle JDK allows you to specify it on the command line with <code>-storepass</code>, you were doing <code>keytool -help</code> instead of <code>keytool -list -help</code>. (I suppose the Android version is the same.)</p> <pre><code>C:\&gt;keytool.exe -list -help keytool...
<p>The <code>keytool</code> that ships with the Oracle JDK allows you to specify it on the command line with <code>-storepass</code>, you were doing <code>keytool -help</code> instead of <code>keytool -list -help</code>. (I suppose the Android version is the same.)</p> <pre><code>C:\&gt;keytool.exe -list -help keytool...
7002, 14422
batch-file, keytool
<h1>Add password to keytool command</h1> <p>I've made a .bat file to get the SHA1 of my Android app so I don't need to type the command each time</p> <p><code>keytool -list -v -keystore "Path/To/My/Key.jks"</code></p> <p>When I run the bat file I get asked for the password. Is it possible to either put the password i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,237
cmd
# Add password to keytool command I've made a .bat file to get the SHA1 of my Android app so I don't need to type the command each time `keytool -list -v -keystore "Path/To/My/Key.jks"` When I run the bat file I get asked for the password. Is it possible to either put the password in the command e.g. something like ...
The `keytool` that ships with the Oracle JDK allows you to specify it on the command line with `-storepass`, you were doing `keytool -help` instead of `keytool -list -help`. (I suppose the Android version is the same.) ``` C:\>keytool.exe -list -help keytool -list [OPTION]... Lists entries in a keystore Options: -...
15658475
How do I make a batch file run strings as commands?
37
2013-03-27 12:11:54
<p>I want to make a batch file to circumvent some cmd problems on my computer, but for that I need to be able to take String user input and run it as a command.</p> <p>Basically what I want to be able to do is type in a command when the batch file asks for input, and have the computer run that command, similar to pyth...
78,244
1,543,167
2023-05-09 15:11:35
15,658,580
58
2013-03-27 12:16:59
2,128,947
2013-03-27 12:16:59
https://stackoverflow.com/q/15658475
https://stackoverflow.com/a/15658580
<p>Simply assign the string to a variable, then "execute" the variable as though it was a program</p> <p>eg </p> <pre><code>set myvar=ECHO Hello, World! %myvar% </code></pre>
<p>Simply assign the string to a variable, then "execute" the variable as though it was a program</p> <p>eg </p> <pre><code>set myvar=ECHO Hello, World! %myvar% </code></pre>
64, 2631, 7002
batch-file, cmd, windows
<h1>How do I make a batch file run strings as commands?</h1> <p>I want to make a batch file to circumvent some cmd problems on my computer, but for that I need to be able to take String user input and run it as a command.</p> <p>Basically what I want to be able to do is type in a command when the batch file asks for i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,238
cmd
# How do I make a batch file run strings as commands? I want to make a batch file to circumvent some cmd problems on my computer, but for that I need to be able to take String user input and run it as a command. Basically what I want to be able to do is type in a command when the batch file asks for input, and have t...
Simply assign the string to a variable, then "execute" the variable as though it was a program eg ``` set myvar=ECHO Hello, World! %myvar% ```
13008255
How to execute a simple Windows command in Golang?
35
2012-10-22 09:18:41
<p><strong>How to run a simple <em>Windows command</em>?</strong></p> <p>This command:</p> <pre><code>exec.Command("del", "c:\\aaa.txt") </code></pre> <p>.. outputs this message:</p> <blockquote> <p>del: executable file not found in %path%</p> </blockquote> <p>What am I doing wrong?</p>
63,789
1,317,559
2023-06-20 18:32:44
13,013,520
58
2012-10-22 14:26:29
694,331
2023-06-20 18:32:44
https://stackoverflow.com/q/13008255
https://stackoverflow.com/a/13013520
<p>I got the same error as you. But dystroy is correct: You can't run <code>del</code> or any other command built into <code>cmd</code> because there is no <code>del.exe</code> file (or any other del-executable for that matter).</p> <p>I got it to work with:</p> <pre class="lang-golang prettyprint-override"><code>packa...
<p>I got the same error as you. But dystroy is correct: You can't run <code>del</code> or any other command built into <code>cmd</code> because there is no <code>del.exe</code> file (or any other del-executable for that matter).</p> <p>I got it to work with:</p> <pre class="lang-golang prettyprint-override"><code>packa...
64, 2631, 15627
cmd, go, windows
<h1>How to execute a simple Windows command in Golang?</h1> <p><strong>How to run a simple <em>Windows command</em>?</strong></p> <p>This command:</p> <pre><code>exec.Command("del", "c:\\aaa.txt") </code></pre> <p>.. outputs this message:</p> <blockquote> <p>del: executable file not found in %path%</p> </blockquo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,239
cmd
# How to execute a simple Windows command in Golang? **How to run a simple *Windows command*?** This command: ``` exec.Command("del", "c:\\aaa.txt") ``` .. outputs this message: > del: executable file not found in %path% What am I doing wrong?
I got the same error as you. But dystroy is correct: You can't run `del` or any other command built into `cmd` because there is no `del.exe` file (or any other del-executable for that matter). I got it to work with: ``` package main import( "fmt" "os/exec" ) func main() { var c *exec.Cmd sw...
6990198
How to return to the original directory after invoking change directory in Windows batch?
34
2011-08-09 00:31:45
<p>I want to create a batch file, <code>batch.bat</code>, that accepts two mandatory arguments:</p> <ul> <li><code>%1</code> represents a path relative to the current directory.</li> <li><code>%2</code> represents a file name.</li> </ul> <p>Assume the current directory is <code>father\me\</code>.</p> <p>User can use th...
30,676
397,524
2025-04-10 05:30:22
6,991,005
58
2011-08-09 03:12:35
778,560
2011-08-09 03:18:32
https://stackoverflow.com/q/6990198
https://stackoverflow.com/a/6991005
<p>If you want to RETURN to original directory, do the first change with <code>PUSHD</code> and return with <code>POPD</code>. That is, moves to %1 directory must be achieved with</p> <pre><code>PUSHD %1 </code></pre> <p>instead of CD %1, and the return is achieved with</p> <pre><code>POPD </code></pre> <p>instead ...
<p>If you want to RETURN to original directory, do the first change with <code>PUSHD</code> and return with <code>POPD</code>. That is, moves to %1 directory must be achieved with</p> <pre><code>PUSHD %1 </code></pre> <p>instead of CD %1, and the return is achieved with</p> <pre><code>POPD </code></pre> <p>instead ...
7002
batch-file
<h1>How to return to the original directory after invoking change directory in Windows batch?</h1> <p>I want to create a batch file, <code>batch.bat</code>, that accepts two mandatory arguments:</p> <ul> <li><code>%1</code> represents a path relative to the current directory.</li> <li><code>%2</code> represents a file ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,240
cmd
# How to return to the original directory after invoking change directory in Windows batch? I want to create a batch file, `batch.bat`, that accepts two mandatory arguments: - `%1` represents a path relative to the current directory. - `%2` represents a file name. Assume the current directory is `father\me\`. User ...
If you want to RETURN to original directory, do the first change with `PUSHD` and return with `POPD`. That is, moves to %1 directory must be achieved with ``` PUSHD %1 ``` instead of CD %1, and the return is achieved with ``` POPD ``` instead of CD where? If you want to ACCESS the original directory after changed ...
34987885
What are the ERRORLEVEL values set by internal cmd.exe commands?
32
2016-01-25 08:16:10
<p>The ERRORLEVEL is a value returned by most cmd.exe commands when they end that change depending on a series of conditions, so knowing the value that the commands return is valuable information that may aid to write better Batch files. All external .exe programs change the ERRORLEVEL when they end (that is an inheren...
50,469
778,560
2022-02-10 20:08:52
34,987,886
58
2016-01-25 08:16:10
778,560
2022-02-10 20:08:52
https://stackoverflow.com/q/34987885
https://stackoverflow.com/a/34987886
<p>In this answer the ERRORLEVEL values returned by all internal cmd.exe commands are described; they are grouped by the way the value is changed and presented as quick reference tables. I reviewed other similar tables in order to assemble this one, but filled the missing values via tests performed in a Windows 8.1 com...
<p>In this answer the ERRORLEVEL values returned by all internal cmd.exe commands are described; they are grouped by the way the value is changed and presented as quick reference tables. I reviewed other similar tables in order to assemble this one, but filled the missing values via tests performed in a Windows 8.1 com...
2631, 7002, 17564
batch-file, cmd, errorlevel
<h1>What are the ERRORLEVEL values set by internal cmd.exe commands?</h1> <p>The ERRORLEVEL is a value returned by most cmd.exe commands when they end that change depending on a series of conditions, so knowing the value that the commands return is valuable information that may aid to write better Batch files. All exte...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,241
cmd
# What are the ERRORLEVEL values set by internal cmd.exe commands? The ERRORLEVEL is a value returned by most cmd.exe commands when they end that change depending on a series of conditions, so knowing the value that the commands return is valuable information that may aid to write better Batch files. All external .exe...
In this answer the ERRORLEVEL values returned by all internal cmd.exe commands are described; they are grouped by the way the value is changed and presented as quick reference tables. I reviewed other similar tables in order to assemble this one, but filled the missing values via tests performed in a Windows 8.1 comput...
14500616
Windows command prompt log to a file
32
2013-01-24 11:45:48
<p>I'd like to easily save the log of the Windows command prompt into a file. Is there any alternative to select everything and right-click on copy?</p>
330,480
1,097,480
2023-11-18 15:27:04
14,500,685
58
2013-01-24 11:49:09
799,586
2013-01-24 11:49:09
https://stackoverflow.com/q/14500616
https://stackoverflow.com/a/14500685
<p>You can redirect the output of a cmd prompt to a file using <code>&gt;</code> or <code>&gt;&gt;</code> to append to a file.</p> <p>i.e.</p> <pre><code>echo Hello World &gt;C:\output.txt echo Hello again! &gt;&gt;C:\output.txt </code></pre> <p>or</p> <pre><code>mybatchfile.bat &gt;C:\output.txt </code></pre> <p>...
<p>You can redirect the output of a cmd prompt to a file using <code>&gt;</code> or <code>&gt;&gt;</code> to append to a file.</p> <p>i.e.</p> <pre><code>echo Hello World &gt;C:\output.txt echo Hello again! &gt;&gt;C:\output.txt </code></pre> <p>or</p> <pre><code>mybatchfile.bat &gt;C:\output.txt </code></pre> <p>...
64, 2631
cmd, windows
<h1>Windows command prompt log to a file</h1> <p>I'd like to easily save the log of the Windows command prompt into a file. Is there any alternative to select everything and right-click on copy?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,242
cmd
# Windows command prompt log to a file I'd like to easily save the log of the Windows command prompt into a file. Is there any alternative to select everything and right-click on copy?
You can redirect the output of a cmd prompt to a file using `>` or `>>` to append to a file. i.e. ``` echo Hello World >C:\output.txt echo Hello again! >>C:\output.txt ``` or ``` mybatchfile.bat >C:\output.txt ``` Note that using `>` will automatically overwrite the file if it already exists. You also have the op...
5811966
Windows Batch Script Get Current Drive name
31
2011-04-27 23:37:40
<p>I have a batch file which is on a usb key. I need to know the drive name the batch is in.</p> <p>Example, if it's E:\mybatch.bat it should find E:\ same thing for F:\, G:\ etc.. when it's opened.</p> <p>How could I do that in batch script. (Windows)</p>
108,234
576,488
2024-01-26 09:05:26
5,811,989
58
2011-04-27 23:40:49
342,745
2016-06-10 22:33:19
https://stackoverflow.com/q/5811966
https://stackoverflow.com/a/5811989
<p><code>%CD%</code> is what you're looking for. It prints the current working directory of the batch file or command running it. If your batch file is on the root of the drive, it will just print the drive letter, otherwise you'll have to parse the first 2 characters.</p> <p>Example:</p> <pre><code>echo %CD% </cod...
<p><code>%CD%</code> is what you're looking for. It prints the current working directory of the batch file or command running it. If your batch file is on the root of the drive, it will just print the drive letter, otherwise you'll have to parse the first 2 characters.</p> <p>Example:</p> <pre><code>echo %CD% </cod...
64, 7002
batch-file, windows
<h1>Windows Batch Script Get Current Drive name</h1> <p>I have a batch file which is on a usb key. I need to know the drive name the batch is in.</p> <p>Example, if it's E:\mybatch.bat it should find E:\ same thing for F:\, G:\ etc.. when it's opened.</p> <p>How could I do that in batch script. (Windows)</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,243
cmd
# Windows Batch Script Get Current Drive name I have a batch file which is on a usb key. I need to know the drive name the batch is in. Example, if it's E:\mybatch.bat it should find E:\ same thing for F:\, G:\ etc.. when it's opened. How could I do that in batch script. (Windows)
`%CD%` is what you're looking for. It prints the current working directory of the batch file or command running it. If your batch file is on the root of the drive, it will just print the drive letter, otherwise you'll have to parse the first 2 characters. Example: ``` echo %CD% ``` prints ``` E:\ ``` on a flash dr...
24397921
Simply compress 1 folder in batch with WinRAR command line?
14
2014-06-24 23:25:32
<p>Using the WinRAR command line <code>(C:\Program Files\WinRAR\rar.exe)</code>, all I'm trying to do is compress a single folder <code>(C:\Users\%username%\desktop\someFolder)</code> and possibly change the name of the .zip file created. I've tried just "rar.exe a "<code>C:\Users\%username%\desktop\someFile</code>" an...
50,683
2,949,024
2018-10-24 17:33:38
24,401,436
58
2014-06-25 06:13:03
3,074,564
2018-10-24 17:33:38
https://stackoverflow.com/q/24397921
https://stackoverflow.com/a/24401436
<p>Use either</p> <pre><code>"%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder" </code></pre> <p>or</p> <pre><code>"%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder\" </code></pre> <p>to cre...
<p>Use either</p> <pre><code>"%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder" </code></pre> <p>or</p> <pre><code>"%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder\" </code></pre> <p>to cre...
7002, 37612
batch-file, winrar
<h1>Simply compress 1 folder in batch with WinRAR command line?</h1> <p>Using the WinRAR command line <code>(C:\Program Files\WinRAR\rar.exe)</code>, all I'm trying to do is compress a single folder <code>(C:\Users\%username%\desktop\someFolder)</code> and possibly change the name of the .zip file created. I've tried j...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,244
cmd
# Simply compress 1 folder in batch with WinRAR command line? Using the WinRAR command line `(C:\Program Files\WinRAR\rar.exe)`, all I'm trying to do is compress a single folder `(C:\Users\%username%\desktop\someFolder)` and possibly change the name of the .zip file created. I've tried just "rar.exe a "`C:\Users\%user...
Use either ``` "%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder" ``` or ``` "%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y "Name of RAR file with path" "%UserProfile%\Desktop\someFolder\" ``` to create a **RAR** archive file with the specified name ...
1472191
Getting the file name without extension in a Windows Batch Script
65
2009-09-24 14:45:32
<p>I'm trying to create a right-click context menu command for compressing JavaScript files with YUI compressor. My ultimate goal is to try to get this to run on a context menu:</p> <pre><code>java.exe -jar yuicompressor-2.4.2.jar -o &lt;filename&gt;.min.js &lt;filename&gt;.js </code></pre> <p>I know I can use the va...
95,281
392
2025-07-22 09:02:25
1,472,212
57
2009-09-24 14:49:40
9,702
2025-07-22 09:02:25
https://stackoverflow.com/q/1472191
https://stackoverflow.com/a/1472212
<p>Change the action to call a batch file:</p> <pre><code>RunCompressor.bat &quot;%1&quot; </code></pre> <p>Use <code>%~n1</code> to get the filename without the extension in RunCompressor.bat:</p> <pre><code>start javaw.exe -jar yuicompressor-2.4.2.jar -o &quot;%~n1.min.js&quot; &quot;%1&quot; </code></pre> <p><a href...
<p>Change the action to call a batch file:</p> <pre><code>RunCompressor.bat &quot;%1&quot; </code></pre> <p>Use <code>%~n1</code> to get the filename without the extension in RunCompressor.bat:</p> <pre><code>start javaw.exe -jar yuicompressor-2.4.2.jar -o &quot;%~n1.min.js&quot; &quot;%1&quot; </code></pre> <p><a href...
64, 1231, 7002
batch-file, command-line, windows
<h1>Getting the file name without extension in a Windows Batch Script</h1> <p>I'm trying to create a right-click context menu command for compressing JavaScript files with YUI compressor. My ultimate goal is to try to get this to run on a context menu:</p> <pre><code>java.exe -jar yuicompressor-2.4.2.jar -o &lt;filena...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,245
cmd
# Getting the file name without extension in a Windows Batch Script I'm trying to create a right-click context menu command for compressing JavaScript files with YUI compressor. My ultimate goal is to try to get this to run on a context menu: ``` java.exe -jar yuicompressor-2.4.2.jar -o <filename>.min.js <filename>.j...
Change the action to call a batch file: ``` RunCompressor.bat "%1" ``` Use `%~n1` to get the filename without the extension in RunCompressor.bat: ``` start javaw.exe -jar yuicompressor-2.4.2.jar -o "%~n1.min.js" "%1" ``` [Helpful article](https://web.archive.org/web/20090107161609/http://windowsitpro.com/article/ar...
24520791
Check if "git stash" stashed anything
56
2014-07-01 23:40:43
<p>I have a Windows Command script designed to merge the <strong>dev</strong> branch into a project branch. It starts by reading the current branch name, stashing changes, fetching and merging the dev and project branches, then switches back to the original branch and pops the stash.</p> <p>The issue is there might n...
28,494
740,923
2025-10-25 16:41:47
24,520,893
57
2014-07-01 23:51:43
3,795,615
2023-03-31 01:17:38
https://stackoverflow.com/q/24520791
https://stackoverflow.com/a/24520893
<p>What you want is:</p> <pre><code>git stash list </code></pre> <hr /> <p><code>git stash</code> allows you to provide a message. You can use a generated token as your message so that you know it won't conflict with other git stash messages.</p> <p>Then, when you want to check whether or not to pop, simply check if th...
<p>What you want is:</p> <pre><code>git stash list </code></pre> <hr /> <p><code>git stash</code> allows you to provide a message. You can use a generated token as your message so that you know it won't conflict with other git stash messages.</p> <p>Then, when you want to check whether or not to pop, simply check if th...
119, 7002, 13091
batch-file, git, git-stash
<h1>Check if "git stash" stashed anything</h1> <p>I have a Windows Command script designed to merge the <strong>dev</strong> branch into a project branch. It starts by reading the current branch name, stashing changes, fetching and merging the dev and project branches, then switches back to the original branch and pop...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,246
cmd
# Check if "git stash" stashed anything I have a Windows Command script designed to merge the **dev** branch into a project branch. It starts by reading the current branch name, stashing changes, fetching and merging the dev and project branches, then switches back to the original branch and pops the stash. The issue...
What you want is: ``` git stash list ``` --- `git stash` allows you to provide a message. You can use a generated token as your message so that you know it won't conflict with other git stash messages. Then, when you want to check whether or not to pop, simply check if the `git stash list` output contains your toke...
3432851
DOS BAT file equivalent to Unix basename command?
51
2010-08-08 02:30:36
<p>Is there an easy way to get to the basename (file name without extension) of a DOS file name using the DOS BAT command language?</p> <p>I agree: <code>format c:\</code> is probably a good start, followed by a bootable Linux CD (assuming these antique machines have a CD reader - not a given). But let's pretend that...
59,030
15,168
2021-11-02 09:10:17
3,432,895
57
2010-08-08 02:55:30
105,662
2021-11-02 09:10:17
https://stackoverflow.com/q/3432851
https://stackoverflow.com/a/3432895
<p><strong>For command-line</strong></p> <pre><code>for /F %i in (&quot;c:\foo\bar.txt&quot;) do @echo %~ni </code></pre> <p><strong>For .bat Files</strong></p> <pre><code>for /F %%i in (&quot;c:\foo\bar.txt&quot;) do @echo %%~ni </code></pre> <p>output: <code>bar</code></p> <p>If the path contains a space, add in <cod...
<p><strong>For command-line</strong></p> <pre><code>for /F %i in (&quot;c:\foo\bar.txt&quot;) do @echo %~ni </code></pre> <p><strong>For .bat Files</strong></p> <pre><code>for /F %%i in (&quot;c:\foo\bar.txt&quot;) do @echo %%~ni </code></pre> <p>output: <code>bar</code></p> <p>If the path contains a space, add in <cod...
5370, 7002
batch-file, dos
<h1>DOS BAT file equivalent to Unix basename command?</h1> <p>Is there an easy way to get to the basename (file name without extension) of a DOS file name using the DOS BAT command language?</p> <p>I agree: <code>format c:\</code> is probably a good start, followed by a bootable Linux CD (assuming these antique machin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,247
cmd
# DOS BAT file equivalent to Unix basename command? Is there an easy way to get to the basename (file name without extension) of a DOS file name using the DOS BAT command language? I agree: `format c:\` is probably a good start, followed by a bootable Linux CD (assuming these antique machines have a CD reader - not a...
**For command-line** ``` for /F %i in ("c:\foo\bar.txt") do @echo %~ni ``` **For .bat Files** ``` for /F %%i in ("c:\foo\bar.txt") do @echo %%~ni ``` output: `bar` If the path contains a space, add in `"delims="` like so: ``` for /F "delims=" %i in ("c:\foo\bar baz.txt") do @echo %~ni ``` output: `bar baz` *(Fu...
15061854
How to pass multiple arguments in processStartInfo?
39
2013-02-25 07:15:33
<p>I want to run some <code>cmd</code> command from <code>c#</code>code. I followed some blogs and tutorial and got the answer, but I am in little bit confused i.e how should I pass multiple arguments?</p> <p>I use follow code:</p> <pre><code>System.Diagnostics.Process process = new System.Diagnostics.Process(); Syst...
146,221
834,239
2025-03-25 04:55:28
15,061,995
57
2013-02-25 07:26:52
2,000,082
2016-12-19 18:50:28
https://stackoverflow.com/q/15061854
https://stackoverflow.com/a/15061995
<p>It is purely a string:</p> <pre><code>startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer" </code></pre> <p>Of course, when arguments contain whitespaces you'll have to escape them using \" \", like:</p> <pre><code>...
<p>It is purely a string:</p> <pre><code>startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer" </code></pre> <p>Of course, when arguments contain whitespaces you'll have to escape them using \" \", like:</p> <pre><code>...
9, 2631, 22546, 42672
c#, cmd, makecert, netsh
<h1>How to pass multiple arguments in processStartInfo?</h1> <p>I want to run some <code>cmd</code> command from <code>c#</code>code. I followed some blogs and tutorial and got the answer, but I am in little bit confused i.e how should I pass multiple arguments?</p> <p>I use follow code:</p> <pre><code>System.Diagnos...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,248
cmd
# How to pass multiple arguments in processStartInfo? I want to run some `cmd` command from `c#`code. I followed some blogs and tutorial and got the answer, but I am in little bit confused i.e how should I pass multiple arguments? I use follow code: ``` System.Diagnostics.Process process = new System.Diagnostics.Pro...
It is purely a string: ``` startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer" ``` Of course, when arguments contain whitespaces you'll have to escape them using \" \", like: ``` "... -ss \"My MyAdHocTestCert.cer\"" `...
45526996
Split audio files using silence detection
34
2017-08-05 22:46:43
<p>I've more than 200 MP3 files and I need to split each one of them by using silence detection. I tried Audacity and WavePad but they do not have batch processes and it's very slow to make them one by one.</p> <p>The scenario is as follows:</p> <ul> <li>split track whereas silence 2 seconds or more</li> <li>then add...
72,469
8,422,836
2024-12-06 15:17:35
46,001,755
57
2017-09-01 13:53:57
5,936,628
2019-04-17 13:43:52
https://stackoverflow.com/q/45526996
https://stackoverflow.com/a/46001755
<p>I found <a href="https://github.com/jiaaro/pydub" rel="noreferrer">pydub</a> to be easiest tool to do this kind of audio manipulation in simple ways and with compact code.</p> <p>You can install <a href="https://github.com/jiaaro/pydub" rel="noreferrer">pydub</a> with</p> <pre><code>pip install pydub </code></pre>...
<p>I found <a href="https://github.com/jiaaro/pydub" rel="noreferrer">pydub</a> to be easiest tool to do this kind of audio manipulation in simple ways and with compact code.</p> <p>You can install <a href="https://github.com/jiaaro/pydub" rel="noreferrer">pydub</a> with</p> <pre><code>pip install pydub </code></pre>...
16, 348, 2193, 7002
audio, batch-file, python, split
<h1>Split audio files using silence detection</h1> <p>I've more than 200 MP3 files and I need to split each one of them by using silence detection. I tried Audacity and WavePad but they do not have batch processes and it's very slow to make them one by one.</p> <p>The scenario is as follows:</p> <ul> <li>split track ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,249
cmd
# Split audio files using silence detection I've more than 200 MP3 files and I need to split each one of them by using silence detection. I tried Audacity and WavePad but they do not have batch processes and it's very slow to make them one by one. The scenario is as follows: - split track whereas silence 2 seconds o...
I found [pydub](https://github.com/jiaaro/pydub) to be easiest tool to do this kind of audio manipulation in simple ways and with compact code. You can install [pydub](https://github.com/jiaaro/pydub) with ``` pip install pydub ``` You may need to install ffmpeg/avlib if needed. See [this link](https://github.com/ji...
8845891
How do you cut and paste a file from one directory to another directory
30
2012-01-13 04:23:05
<p>How do I cut and paste one file from one directory to another directory? I want to do this task using the Command Prompt.</p> <p>I know I can do this by using the GUI, but I am curious about if I can do this using batch scripting since I am trying to learn it.</p>
189,931
960,436
2023-02-28 02:09:54
8,845,928
57
2012-01-13 04:26:40
118,068
2012-01-13 04:26:40
https://stackoverflow.com/q/8845891
https://stackoverflow.com/a/8845928
<p><code>mv</code> in unix-ish systems, <code>move</code> in dos/windows.</p> <p>e.g.</p> <pre><code>C:\&gt; move c:\users\you\somefile.txt c:\temp\newlocation.txt </code></pre> <p>and</p> <pre><code>$ mv /home/you/somefile.txt /tmp/newlocation.txt </code></pre>
<p><code>mv</code> in unix-ish systems, <code>move</code> in dos/windows.</p> <p>e.g.</p> <pre><code>C:\&gt; move c:\users\you\somefile.txt c:\temp\newlocation.txt </code></pre> <p>and</p> <pre><code>$ mv /home/you/somefile.txt /tmp/newlocation.txt </code></pre>
64, 1231, 7002
batch-file, command-line, windows
<h1>How do you cut and paste a file from one directory to another directory</h1> <p>How do I cut and paste one file from one directory to another directory? I want to do this task using the Command Prompt.</p> <p>I know I can do this by using the GUI, but I am curious about if I can do this using batch scripting since ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,250
cmd
# How do you cut and paste a file from one directory to another directory How do I cut and paste one file from one directory to another directory? I want to do this task using the Command Prompt. I know I can do this by using the GUI, but I am curious about if I can do this using batch scripting since I am trying to ...
`mv` in unix-ish systems, `move` in dos/windows. e.g. ``` C:\> move c:\users\you\somefile.txt c:\temp\newlocation.txt ``` and ``` $ mv /home/you/somefile.txt /tmp/newlocation.txt ```
20105735
Error "The syntax of the command is incorrect" when renaming a file
21
2013-11-20 19:59:13
<p>I get this error on this step of my SQL 2005 process:</p> <pre><code>rename "G:\AuthorsList\AuthorsList_New.mdb""G:\AuthorsList\AuthorsListCopy.mdb" </code></pre> <p>I am trying to rename the file. I have also tried this and get the same error:</p> <pre><code>rename "G:\AuthorsList\AuthorsList_New.mdb" "G:\Autho...
48,760
2,821,300
2023-10-19 20:49:08
20,106,012
57
2013-11-20 20:12:34
95
2019-01-28 08:02:54
https://stackoverflow.com/q/20105735
https://stackoverflow.com/a/20106012
<p>Check the documentation for the <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren?view=sc-vmm-1801" rel="noreferrer">rename</a> command:</p> <blockquote> <p><strong>Syntax</strong><br> <code>rename [Drive:][Path]filename1 filename2</code></p> <p><strong>Parameter...
<p>Check the documentation for the <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren?view=sc-vmm-1801" rel="noreferrer">rename</a> command:</p> <blockquote> <p><strong>Syntax</strong><br> <code>rename [Drive:][Path]filename1 filename2</code></p> <p><strong>Parameter...
64, 1231, 7002
batch-file, command-line, windows
<h1>Error "The syntax of the command is incorrect" when renaming a file</h1> <p>I get this error on this step of my SQL 2005 process:</p> <pre><code>rename "G:\AuthorsList\AuthorsList_New.mdb""G:\AuthorsList\AuthorsListCopy.mdb" </code></pre> <p>I am trying to rename the file. I have also tried this and get the same...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,251
cmd
# Error "The syntax of the command is incorrect" when renaming a file I get this error on this step of my SQL 2005 process: ``` rename "G:\AuthorsList\AuthorsList_New.mdb""G:\AuthorsList\AuthorsListCopy.mdb" ``` I am trying to rename the file. I have also tried this and get the same error: ``` rename "G:\AuthorsLis...
Check the documentation for the [rename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren?view=sc-vmm-1801) command: > **Syntax** > `rename [Drive:][Path]filename1 filename2` > > **Parameters** > `[Drive:][Path]filename1`: Specifies the location and name of the file or set of fi...
25968099
Configure Intellij IDEA to run batch file
45
2014-09-22 06:48:49
<p>I'm using InteliJ IDEA (Community addition) and I found myself doing some file transfers to and from the project folder. After reapeating the task for a while I've created some batch scripts that transfering the files automaticly. Now, I'll be much more happy if I could run the scripts directly from the IDE - by pre...
49,120
1,726,419
2022-07-27 14:59:48
25,970,200
56
2014-09-22 09:01:30
916,225
2017-04-06 05:56:26
https://stackoverflow.com/q/25968099
https://stackoverflow.com/a/25970200
<p>You can use "External Tools" to invoke any program</p> <p>Goto <code>Settings-&gt;External Tools</code> and create a tool which will open the following dialog choose the batch file for <code>Program</code>. </p> <p><a href="https://i.sstatic.net/8Gdcc.png" rel="noreferrer"><img src="https://i.sstatic.net/8Gdcc.png...
<p>You can use "External Tools" to invoke any program</p> <p>Goto <code>Settings-&gt;External Tools</code> and create a tool which will open the following dialog choose the batch file for <code>Program</code>. </p> <p><a href="https://i.sstatic.net/8Gdcc.png" rel="noreferrer"><img src="https://i.sstatic.net/8Gdcc.png...
487, 7002, 8945
batch-file, build-automation, intellij-idea
<h1>Configure Intellij IDEA to run batch file</h1> <p>I'm using InteliJ IDEA (Community addition) and I found myself doing some file transfers to and from the project folder. After reapeating the task for a while I've created some batch scripts that transfering the files automaticly. Now, I'll be much more happy if I c...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,252
cmd
# Configure Intellij IDEA to run batch file I'm using InteliJ IDEA (Community addition) and I found myself doing some file transfers to and from the project folder. After reapeating the task for a while I've created some batch scripts that transfering the files automaticly. Now, I'll be much more happy if I could run ...
You can use "External Tools" to invoke any program Goto `Settings->External Tools` and create a tool which will open the following dialog choose the batch file for `Program`. [![Create Tool Dialog](https://i.sstatic.net/8Gdcc.png)](https://i.sstatic.net/8Gdcc.png) Then the tool will be available in the menu `Tools` ...
8192318
Why does delayed expansion fail when inside a piped block of code?
45
2011-11-19 06:19:33
<p>Here is a simple batch file that demonstrates how delayed expansion fails if it is within a block that is being piped. (The failure is toward the end of the script) Can anyone explain why this is?</p> <p>I have a work-around, but it requires creation of a temporary file. I initially ran into this problem while work...
22,047
1,012,053
2022-11-29 20:03:12
8,194,279
56
2011-11-19 13:13:37
463,115
2022-11-29 20:03:12
https://stackoverflow.com/q/8192318
https://stackoverflow.com/a/8194279
<p>As <a href="https://stackoverflow.com/users/778560/aacini">Aacini</a> shows, it seems that many things fail within a pipe.</p> <pre><code>echo hello | set /p var= echo here | call :function </code></pre> <p>But in reality it's only a problem to understand how the pipe works.</p> <p>Each side of a pipe starts its own...
<p>As <a href="https://stackoverflow.com/users/778560/aacini">Aacini</a> shows, it seems that many things fail within a pipe.</p> <pre><code>echo hello | set /p var= echo here | call :function </code></pre> <p>But in reality it's only a problem to understand how the pipe works.</p> <p>Each side of a pipe starts its own...
5813, 7002
batch-file, pipe
<h1>Why does delayed expansion fail when inside a piped block of code?</h1> <p>Here is a simple batch file that demonstrates how delayed expansion fails if it is within a block that is being piped. (The failure is toward the end of the script) Can anyone explain why this is?</p> <p>I have a work-around, but it require...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,253
cmd
# Why does delayed expansion fail when inside a piped block of code? Here is a simple batch file that demonstrates how delayed expansion fails if it is within a block that is being piped. (The failure is toward the end of the script) Can anyone explain why this is? I have a work-around, but it requires creation of a ...
As [Aacini](https://stackoverflow.com/users/778560/aacini) shows, it seems that many things fail within a pipe. ``` echo hello | set /p var= echo here | call :function ``` But in reality it's only a problem to understand how the pipe works. Each side of a pipe starts its own cmd.exe in its own asynchronous thread. ...
5417979
Batch rename sequential files by padding with zeroes
41
2011-03-24 10:49:37
<p>I have a bunch of files named like so:</p> <pre><code>output_1.png output_2.png ... output_10.png ... output_120.png </code></pre> <p>What is the easiest way of renaming those to match a convention, e.g. with maximum four decimals, so that the files are named:</p> <pre><code>output_0001.png output_0002.png ... ou...
44,759
435,093
2021-08-10 03:19:42
5,418,035
56
2011-03-24 10:54:53
635,411
2011-03-24 13:45:56
https://stackoverflow.com/q/5417979
https://stackoverflow.com/a/5418035
<h2>Python</h2> <pre><code>import os path = '/path/to/files/' for filename in os.listdir(path): prefix, num = filename[:-4].split('_') num = num.zfill(4) new_filename = prefix + "_" + num + ".png" os.rename(os.path.join(path, filename), os.path.join(path, new_filename)) </code></pre> <p>you could comp...
<h2>Python</h2> <pre><code>import os path = '/path/to/files/' for filename in os.listdir(path): prefix, num = filename[:-4].split('_') num = num.zfill(4) new_filename = prefix + "_" + num + ".png" os.rename(os.path.join(path, filename), os.path.join(path, new_filename)) </code></pre> <p>you could comp...
4510, 7002, 13475
batch-file, batch-rename, rename
<h1>Batch rename sequential files by padding with zeroes</h1> <p>I have a bunch of files named like so:</p> <pre><code>output_1.png output_2.png ... output_10.png ... output_120.png </code></pre> <p>What is the easiest way of renaming those to match a convention, e.g. with maximum four decimals, so that the files are...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,254
cmd
# Batch rename sequential files by padding with zeroes I have a bunch of files named like so: ``` output_1.png output_2.png ... output_10.png ... output_120.png ``` What is the easiest way of renaming those to match a convention, e.g. with maximum four decimals, so that the files are named: ``` output_0001.png outp...
## Python ``` import os path = '/path/to/files/' for filename in os.listdir(path): prefix, num = filename[:-4].split('_') num = num.zfill(4) new_filename = prefix + "_" + num + ".png" os.rename(os.path.join(path, filename), os.path.join(path, new_filename)) ``` you could compile a list of valid filena...
10227144
Convert long filename to short filename (8.3) using cmd.exe
39
2012-04-19 11:35:37
<p>I am trying to convert a long filename to a short filename (8.3) on Windows.</p> <p>A batch-file with a command line argument works as intended:</p> <p><em>short.bat</em>:</p> <pre><code>@echo OFF echo %~s1 </code></pre> <p>calling <code>short.bat C:\Documents and Settings\User\NTUSER.DAT</code> returns <code>C:...
87,507
1,251,007
2020-04-10 10:50:31
10,227,715
56
2012-04-19 12:08:20
1,012,053
2012-04-19 12:08:20
https://stackoverflow.com/q/10227144
https://stackoverflow.com/a/10227715
<pre><code>cmd /c for %A in ("C:\Documents and Settings\User\NTUSER.DAT") do @echo %~sA </code></pre>
<pre><code>cmd /c for %A in ("C:\Documents and Settings\User\NTUSER.DAT") do @echo %~sA </code></pre>
64, 1231, 7002, 27094, 37114
batch-file, command-line, long-filenames, short-filenames, windows
<h1>Convert long filename to short filename (8.3) using cmd.exe</h1> <p>I am trying to convert a long filename to a short filename (8.3) on Windows.</p> <p>A batch-file with a command line argument works as intended:</p> <p><em>short.bat</em>:</p> <pre><code>@echo OFF echo %~s1 </code></pre> <p>calling <code>short....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,255
cmd
# Convert long filename to short filename (8.3) using cmd.exe I am trying to convert a long filename to a short filename (8.3) on Windows. A batch-file with a command line argument works as intended: *short.bat*: ``` @echo OFF echo %~s1 ``` calling `short.bat C:\Documents and Settings\User\NTUSER.DAT` returns `C:\...
``` cmd /c for %A in ("C:\Documents and Settings\User\NTUSER.DAT") do @echo %~sA ```
10552589
use cmd.exe to change directory and run command in that directory
37
2012-05-11 13:44:12
<p>All I want to do is:</p> <ol> <li>change to specific directory of a different drive</li> <li>run a command in that directory e.g. dir</li> </ol> <p>I need to do this in one line using cmd.exe starting from a different drive</p> <p>I would do this like this:</p> <pre><code>c: cd temp dir </code></pre> <p>so in ...
100,567
214,518
2014-07-04 08:16:40
10,553,523
56
2012-05-11 14:39:34
21,567
2012-05-11 17:32:58
https://stackoverflow.com/q/10552589
https://stackoverflow.com/a/10553523
<p>You may want to invoke CD with the /d option, thus not only changing the current directory on drive c: but also going there (in case you are not already on that drive).</p> <pre><code> cmd /c "cd /d c:\temp &amp;&amp; dir" </code></pre>
<p>You may want to invoke CD with the /d option, thus not only changing the current directory on drive c: but also going there (in case you are not already on that drive).</p> <pre><code> cmd /c "cd /d c:\temp &amp;&amp; dir" </code></pre>
2631
cmd
<h1>use cmd.exe to change directory and run command in that directory</h1> <p>All I want to do is:</p> <ol> <li>change to specific directory of a different drive</li> <li>run a command in that directory e.g. dir</li> </ol> <p>I need to do this in one line using cmd.exe starting from a different drive</p> <p>I would ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,256
cmd
# use cmd.exe to change directory and run command in that directory All I want to do is: 1. change to specific directory of a different drive 2. run a command in that directory e.g. dir I need to do this in one line using cmd.exe starting from a different drive I would do this like this: ``` c: cd temp dir ``` so...
You may want to invoke CD with the /d option, thus not only changing the current directory on drive c: but also going there (in case you are not already on that drive). ``` cmd /c "cd /d c:\temp && dir" ```
6401928
Batch File - Remove Second File Extension
34
2011-06-19 10:50:40
<p>Using a batch file is there a way that I can strip off the .deploy extension from all files in a directory.</p> <p>For example </p> <pre><code>1.txt.deploy =&gt; 1.txt 2.txt.deploy =&gt; 2.txt </code></pre> <p>etc</p>
46,956
207,992
2018-03-08 15:39:30
6,403,418
56
2011-06-19 15:45:13
297,408
2011-06-19 15:45:13
https://stackoverflow.com/q/6401928
https://stackoverflow.com/a/6403418
<pre><code>RENAME *.txt.deploy *. </code></pre> <p>A more 'fancy' solution:</p> <pre><code>@ECHO OFF FOR %%f IN (*.txt.deploy) DO RENAME "%%f" "%%~nf" </code></pre>
<pre><code>RENAME *.txt.deploy *. </code></pre> <p>A more 'fancy' solution:</p> <pre><code>@ECHO OFF FOR %%f IN (*.txt.deploy) DO RENAME "%%f" "%%~nf" </code></pre>
4510, 7002
batch-file, rename
<h1>Batch File - Remove Second File Extension</h1> <p>Using a batch file is there a way that I can strip off the .deploy extension from all files in a directory.</p> <p>For example </p> <pre><code>1.txt.deploy =&gt; 1.txt 2.txt.deploy =&gt; 2.txt </code></pre> <p>etc</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,257
cmd
# Batch File - Remove Second File Extension Using a batch file is there a way that I can strip off the .deploy extension from all files in a directory. For example ``` 1.txt.deploy => 1.txt 2.txt.deploy => 2.txt ``` etc
``` RENAME *.txt.deploy *. ``` A more 'fancy' solution: ``` @ECHO OFF FOR %%f IN (*.txt.deploy) DO RENAME "%%f" "%%~nf" ```
1738985
Why %processor_architecture% always returns x86 instead of AMD64
34
2009-11-15 21:54:48
<p>I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable <code>%processor_architecture%</code> is returning <code>x86</code> instead of <code>AMD64</code>.</p> <p>Does anyone has any clue about this?</p>
62,041
21,918
2024-02-17 07:52:42
1,739,055
56
2009-11-15 22:15:04
19,404
2016-10-13 15:08:30
https://stackoverflow.com/q/1738985
https://stackoverflow.com/a/1739055
<p>You may be getting the wrong environment variable. If your application is a 32-bit application running on a 64-bit OS the process version of this environment variable will return x86. If you want to find the architecture of the machine, you can grab it from the following registry entry:</p> <pre><code>HKEY_LOCAL_MA...
<p>You may be getting the wrong environment variable. If your application is a 32-bit application running on a 64-bit OS the process version of this environment variable will return x86. If you want to find the architecture of the machine, you can grab it from the following registry entry:</p> <pre><code>HKEY_LOCAL_MA...
64, 1231, 7002
batch-file, command-line, windows
<h1>Why %processor_architecture% always returns x86 instead of AMD64</h1> <p>I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable <code>%processor_architecture%</code> is returning <code>x86</code> instead of <code>AMD64</code>.</p>...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,258
cmd
# Why %processor_architecture% always returns x86 instead of AMD64 I am trying to retrieve the environment variable to detect whether the system is 32 or 64 bit. But on 64 bit server the environment variable `%processor_architecture%` is returning `x86` instead of `AMD64`. Does anyone has any clue about this?
You may be getting the wrong environment variable. If your application is a 32-bit application running on a 64-bit OS the process version of this environment variable will return x86. If you want to find the architecture of the machine, you can grab it from the following registry entry: ``` HKEY_LOCAL_MACHINE\System\C...
11481150
Batch file call sub-batch file to pass n paramenters and return without use of file
33
2012-07-14 04:47:33
<p>I looking for a way using windows batch file that call sub-batch file which pass 1-9 parameters and return value (string) without the need of saving the return value into file/etc. The return value I save into variable like did in @FOR /F</p> <p>I look at </p> <pre><code>@FOR /F "tokens=*" %%i IN ('%find_OS_versio...
104,887
1,175,681
2017-03-06 03:59:55
11,486,159
56
2012-07-14 18:09:18
1,012,053
2017-03-06 03:59:55
https://stackoverflow.com/q/11481150
https://stackoverflow.com/a/11486159
<p>Generally batch functions return values in one of two ways:</p> <p>1) A single integer value can be returned via the errorlevel by using <code>EXIT /B n</code> where n = some number.</p> <pre><code>@echo off setlocal call :sum 1 2 echo the answer is %errorlevel% exit /b :sum setlocal set /a "rtn=%1 + %2" exit /b ...
<p>Generally batch functions return values in one of two ways:</p> <p>1) A single integer value can be returned via the errorlevel by using <code>EXIT /B n</code> where n = some number.</p> <pre><code>@echo off setlocal call :sum 1 2 echo the answer is %errorlevel% exit /b :sum setlocal set /a "rtn=%1 + %2" exit /b ...
7002
batch-file
<h1>Batch file call sub-batch file to pass n paramenters and return without use of file</h1> <p>I looking for a way using windows batch file that call sub-batch file which pass 1-9 parameters and return value (string) without the need of saving the return value into file/etc. The return value I save into variable like ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,259
cmd
# Batch file call sub-batch file to pass n paramenters and return without use of file I looking for a way using windows batch file that call sub-batch file which pass 1-9 parameters and return value (string) without the need of saving the return value into file/etc. The return value I save into variable like did in @F...
Generally batch functions return values in one of two ways: 1) A single integer value can be returned via the errorlevel by using `EXIT /B n` where n = some number. ``` @echo off setlocal call :sum 1 2 echo the answer is %errorlevel% exit /b :sum setlocal set /a "rtn=%1 + %2" exit /b %rtn% ``` 2) The more flexible ...
2507878
Commit all folders and files in a directory using commandline
29
2010-03-24 13:13:23
<p>We are having trouble with having a generalized approach to committing with a batch file using commandline SVN.</p> <p>We've got a backup script that created a new folder with the current date containing the database dumps of our database. (Yes, we version control our database).</p> <p>Now how can I use the <code>...
66,165
113,142
2016-12-17 18:52:23
2,508,201
56
2010-03-24 14:00:00
2,094
2016-12-17 18:52:23
https://stackoverflow.com/q/2507878
https://stackoverflow.com/a/2508201
<p><code>svn add --force .</code> will add all the files and directories below your current working directory that aren't added yet (and aren't ignored) to your working copy.</p> <p>A <code>svn ci -m ""</code> will then handle the commit.</p> <p>The only way without 'svn add' would be to use 'svn import', but this as...
<p><code>svn add --force .</code> will add all the files and directories below your current working directory that aren't added yet (and aren't ignored) to your working copy.</p> <p>A <code>svn ci -m ""</code> will then handle the commit.</p> <p>The only way without 'svn add' would be to use 'svn import', but this as...
63, 1231, 2631
cmd, command-line, svn
<h1>Commit all folders and files in a directory using commandline</h1> <p>We are having trouble with having a generalized approach to committing with a batch file using commandline SVN.</p> <p>We've got a backup script that created a new folder with the current date containing the database dumps of our database. (Yes,...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,260
cmd
# Commit all folders and files in a directory using commandline We are having trouble with having a generalized approach to committing with a batch file using commandline SVN. We've got a backup script that created a new folder with the current date containing the database dumps of our database. (Yes, we version cont...
`svn add --force .` will add all the files and directories below your current working directory that aren't added yet (and aren't ignored) to your working copy. A `svn ci -m ""` will then handle the commit. The only way without 'svn add' would be to use 'svn import', but this assumes a new location.
17106181
how to clear a variable which is set from command line by "set /p var1="
27
2013-06-14 10:14:43
<p>In Windows batch files, I accept variable from user input by <code>set /p var1=</code>, after <code>var1</code> is used, I don't know how to reset/clear its value. </p> <p>If I don't reset/clear its value, when user meets <code>set /p var1=</code> again, and user enter directly. the previous input value will be sti...
83,303
2,118,405
2023-02-22 13:08:39
17,106,863
56
2013-06-14 10:54:30
1,012,053
2015-06-03 11:43:25
https://stackoverflow.com/q/17106181
https://stackoverflow.com/a/17106863
<p>To clear a variable, regardless how it was set:</p> <pre><code>set "var1=" </code></pre>
<p>To clear a variable, regardless how it was set:</p> <pre><code>set "var1=" </code></pre>
7002
batch-file
<h1>how to clear a variable which is set from command line by "set /p var1="</h1> <p>In Windows batch files, I accept variable from user input by <code>set /p var1=</code>, after <code>var1</code> is used, I don't know how to reset/clear its value. </p> <p>If I don't reset/clear its value, when user meets <code>set /p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,261
cmd
# how to clear a variable which is set from command line by "set /p var1=" In Windows batch files, I accept variable from user input by `set /p var1=`, after `var1` is used, I don't know how to reset/clear its value. If I don't reset/clear its value, when user meets `set /p var1=` again, and user enter directly. the ...
To clear a variable, regardless how it was set: ``` set "var1=" ```
25270885
installing cx_Freeze to python at windows
26
2014-08-12 17:48:23
<p>I am using python 3.4 at win-8. I want to obtain .exe program from python code. I learned that it can be done by cx_Freeze.</p> <p>In MS-DOS command line, I wrote pip install cx_Freeze to set up cx_Freeze. It is installed but it is not working. </p> <p>(When I wrote cxfreeze to command line, I get this warning:C:...
28,732
3,934,552
2015-10-20 18:54:29
25,936,813
56
2014-09-19 14:56:32
1,504,026
2014-09-22 08:23:46
https://stackoverflow.com/q/25270885
https://stackoverflow.com/a/25936813
<p>I faced a similar problem (Python 3.4 32-bit, on Windows 7 64-bit). After installation of cx_freeze, three files appeared in <code>c:\Python34\Scripts\</code>:</p> <ul> <li><code>cxfreeze</code></li> <li><code>cxfreeze-postinstall</code></li> <li><code>cxfreeze-quickstart</code></li> </ul> <p>These files have no f...
<p>I faced a similar problem (Python 3.4 32-bit, on Windows 7 64-bit). After installation of cx_freeze, three files appeared in <code>c:\Python34\Scripts\</code>:</p> <ul> <li><code>cxfreeze</code></li> <li><code>cxfreeze-postinstall</code></li> <li><code>cxfreeze-quickstart</code></li> </ul> <p>These files have no f...
16, 7002, 50154, 60010
batch-file, cx-freeze, python, python-3.x
<h1>installing cx_Freeze to python at windows</h1> <p>I am using python 3.4 at win-8. I want to obtain .exe program from python code. I learned that it can be done by cx_Freeze.</p> <p>In MS-DOS command line, I wrote pip install cx_Freeze to set up cx_Freeze. It is installed but it is not working. </p> <p>(When I wr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,262
cmd
# installing cx_Freeze to python at windows I am using python 3.4 at win-8. I want to obtain .exe program from python code. I learned that it can be done by cx_Freeze. In MS-DOS command line, I wrote pip install cx_Freeze to set up cx_Freeze. It is installed but it is not working. (When I wrote cxfreeze to command l...
I faced a similar problem (Python 3.4 32-bit, on Windows 7 64-bit). After installation of cx_freeze, three files appeared in `c:\Python34\Scripts\`: - `cxfreeze` - `cxfreeze-postinstall` - `cxfreeze-quickstart` These files have no file extensions, but appear to be Python scripts. When you run `python.exe cxfreeze-pos...
5944180
How do you run a command as an administrator from the Windows command line?
104
2011-05-10 01:13:50
<p>I have a small script that performs the build and install process on Windows for a <a href="http://en.wikipedia.org/wiki/Bazaar_%28software%29" rel="noreferrer">Bazaar</a> repository I'm managing. I'm trying to run the script with elevated, administrative privileges from <em>within</em> the Windows shell (cmd.exe)--...
590,640
712,526
2023-11-21 12:54:02
5,969,764
55
2011-05-11 19:47:15
3,501
2011-05-11 19:47:15
https://stackoverflow.com/q/5944180
https://stackoverflow.com/a/5969764
<p>A batch/WSH hybrid is able to call ShellExecute to display the UAC elevation dialog...</p> <pre><code>@if (1==1) @if(1==0) @ELSE @echo off&amp;SETLOCAL ENABLEEXTENSIONS &gt;nul 2&gt;&amp;1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||( cscript //E:JScript //nologo "%~f0" @goto :E...
<p>A batch/WSH hybrid is able to call ShellExecute to display the UAC elevation dialog...</p> <pre><code>@if (1==1) @if(1==0) @ELSE @echo off&amp;SETLOCAL ENABLEEXTENSIONS &gt;nul 2&gt;&amp;1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||( cscript //E:JScript //nologo "%~f0" @goto :E...
2631, 28223, 34595
cmd, windows-7, windows-vista
<h1>How do you run a command as an administrator from the Windows command line?</h1> <p>I have a small script that performs the build and install process on Windows for a <a href="http://en.wikipedia.org/wiki/Bazaar_%28software%29" rel="noreferrer">Bazaar</a> repository I'm managing. I'm trying to run the script with e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,263
cmd
# How do you run a command as an administrator from the Windows command line? I have a small script that performs the build and install process on Windows for a [Bazaar](http://en.wikipedia.org/wiki/Bazaar_%28software%29) repository I'm managing. I'm trying to run the script with elevated, administrative privileges fr...
A batch/WSH hybrid is able to call ShellExecute to display the UAC elevation dialog... ``` @if (1==1) @if(1==0) @ELSE @echo off&SETLOCAL ENABLEEXTENSIONS >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||( cscript //E:JScript //nologo "%~f0" @goto :EOF ) echo.Performing admin t...
3400884
How do I open an Explorer window in a given directory from cmd.exe?
62
2010-08-03 21:28:55
<p>I see how to launch <a href="http://ss64.com/nt/syntax-run-commands.html" rel="noreferrer">many other programs</a> from a batch file, but I can't find a command like <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/open.1.html" rel="noreferrer"><code>open</code></a> on Mac...
162,029
143,913
2024-10-07 17:20:29
3,400,901
55
2010-08-03 21:31:29
114,029
2010-08-03 21:36:45
https://stackoverflow.com/q/3400884
https://stackoverflow.com/a/3400901
<p>In Windows you can open Explorer with the following command:</p> <pre><code>C:\Users\Leniel&gt;start %windir%\explorer.exe </code></pre> <p>If you want it to open a specific folder, do this for example:</p> <pre><code>C:\Users\Leniel&gt;start %windir%\explorer.exe "C:\Users\Leniel\Desktop" </code></pre>
<p>In Windows you can open Explorer with the following command:</p> <pre><code>C:\Users\Leniel&gt;start %windir%\explorer.exe </code></pre> <p>If you want it to open a specific folder, do this for example:</p> <pre><code>C:\Users\Leniel&gt;start %windir%\explorer.exe "C:\Users\Leniel\Desktop" </code></pre>
64, 531, 2631
cmd, scripting, windows
<h1>How do I open an Explorer window in a given directory from cmd.exe?</h1> <p>I see how to launch <a href="http://ss64.com/nt/syntax-run-commands.html" rel="noreferrer">many other programs</a> from a batch file, but I can't find a command like <a href="http://developer.apple.com/mac/library/documentation/Darwin/Refer...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,264
cmd
# How do I open an Explorer window in a given directory from cmd.exe? I see how to launch [many other programs](http://ss64.com/nt/syntax-run-commands.html) from a batch file, but I can't find a command like [`open`](http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/open.1.html) on Ma...
In Windows you can open Explorer with the following command: ``` C:\Users\Leniel>start %windir%\explorer.exe ``` If you want it to open a specific folder, do this for example: ``` C:\Users\Leniel>start %windir%\explorer.exe "C:\Users\Leniel\Desktop" ```
3854026
How to give credentials in a batch script that copies files to a network location?
47
2010-10-04 09:34:23
<p>The environment is Windows Web Server 2008, and I'm just trying to copy a folder full of files to a network location (a managed backup network folder). Here is my .bat file, running in the folder with my .bat files:</p> <pre><code>copy *.bak \\networklocation\*.bak pause </code></pre> <p>however <strong>\\networkl...
193,914
200,882
2021-01-25 16:27:34
3,854,055
55
2010-10-04 09:38:52
166,132
2021-01-25 16:27:34
https://stackoverflow.com/q/3854026
https://stackoverflow.com/a/3854055
<p>Try using the <code>net use</code> command in your script to map the share first, because you can provide it credentials. Then, your copy command should use those credentials.</p> <pre><code>net use \\&lt;network-location&gt;\&lt;some-share&gt; password /USER:username </code></pre> <p>Don't leave a trailing \ at the...
<p>Try using the <code>net use</code> command in your script to map the share first, because you can provide it credentials. Then, your copy command should use those credentials.</p> <pre><code>net use \\&lt;network-location&gt;\&lt;some-share&gt; password /USER:username </code></pre> <p>Don't leave a trailing \ at the...
220, 359, 794, 7002
batch-file, network-programming, passwords, permissions
<h1>How to give credentials in a batch script that copies files to a network location?</h1> <p>The environment is Windows Web Server 2008, and I'm just trying to copy a folder full of files to a network location (a managed backup network folder). Here is my .bat file, running in the folder with my .bat files:</p> <pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,265
cmd
# How to give credentials in a batch script that copies files to a network location? The environment is Windows Web Server 2008, and I'm just trying to copy a folder full of files to a network location (a managed backup network folder). Here is my .bat file, running in the folder with my .bat files: ``` copy *.bak \\...
Try using the `net use` command in your script to map the share first, because you can provide it credentials. Then, your copy command should use those credentials. ``` net use \\<network-location>\<some-share> password /USER:username ``` Don't leave a trailing \ at the end of the
19960332
Use slurm job id
41
2013-11-13 17:23:25
<p>When I launch a computation on the cluster, I usually have a separate program doing the post-processing at the end :</p> <pre><code>sbatch simulation sbatch --dependency=afterok:JOBIDHERE postprocessing </code></pre> <p>I want to avoid mistyping and automatically have the good job id inserted. Any idea? Thanks</p>...
21,826
1,824,346
2017-07-18 07:34:08
20,021,078
55
2013-11-16 16:52:03
1,763,614
2013-11-16 16:52:03
https://stackoverflow.com/q/19960332
https://stackoverflow.com/a/20021078
<p>You can do something like this:</p> <pre><code>RES=$(sbatch simulation) &amp;&amp; sbatch --dependency=afterok:${RES##* } postprocessing </code></pre> <p>The <code>RES</code> variable will hold the result of the <code>sbatch</code> command, something like <code>Submitted batch job 102045</code>. The construct <cod...
<p>You can do something like this:</p> <pre><code>RES=$(sbatch simulation) &amp;&amp; sbatch --dependency=afterok:${RES##* } postprocessing </code></pre> <p>The <code>RES</code> variable will hold the result of the <code>sbatch</code> command, something like <code>Submitted batch job 102045</code>. The construct <cod...
58, 3250, 30645, 97759
batch-processing, hpc, linux, slurm
<h1>Use slurm job id</h1> <p>When I launch a computation on the cluster, I usually have a separate program doing the post-processing at the end :</p> <pre><code>sbatch simulation sbatch --dependency=afterok:JOBIDHERE postprocessing </code></pre> <p>I want to avoid mistyping and automatically have the good job id inse...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,266
cmd
# Use slurm job id When I launch a computation on the cluster, I usually have a separate program doing the post-processing at the end : ``` sbatch simulation sbatch --dependency=afterok:JOBIDHERE postprocessing ``` I want to avoid mistyping and automatically have the good job id inserted. Any idea? Thanks
You can do something like this: ``` RES=$(sbatch simulation) && sbatch --dependency=afterok:${RES##* } postprocessing ``` The `RES` variable will hold the result of the `sbatch` command, something like `Submitted batch job 102045`. The construct `${RES##* }` isolates the last word (see more info [here](http://tldp.or...
2888851
How to stop process from .BAT file?
41
2010-05-22 16:26:08
<p>So I have process I started from one bat file. How to stop it from another?</p>
205,307
434,051
2022-04-19 04:20:17
2,888,874
55
2010-05-22 16:34:39
103,225
2010-05-22 16:34:39
https://stackoverflow.com/q/2888851
https://stackoverflow.com/a/2888874
<p>To terminate a process you know the name of, try:</p> <pre><code>taskkill /IM notepad.exe </code></pre> <p>This will ask it to close, but it may refuse, offer to "save changes", etc. If you want to forcibly kill it, try:</p> <pre><code>taskkill /F /IM notepad.exe </code></pre>
<p>To terminate a process you know the name of, try:</p> <pre><code>taskkill /IM notepad.exe </code></pre> <p>This will ask it to close, but it may refuse, offer to "save changes", etc. If you want to forcibly kill it, try:</p> <pre><code>taskkill /F /IM notepad.exe </code></pre>
5310, 5910, 7002
batch-file, file, process
<h1>How to stop process from .BAT file?</h1> <p>So I have process I started from one bat file. How to stop it from another?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,267
cmd
# How to stop process from .BAT file? So I have process I started from one bat file. How to stop it from another?
To terminate a process you know the name of, try: ``` taskkill /IM notepad.exe ``` This will ask it to close, but it may refuse, offer to "save changes", etc. If you want to forcibly kill it, try: ``` taskkill /F /IM notepad.exe ```
7164184
Suppress directory names being listed with DIR
26
2011-08-23 16:15:29
<p>I want to list the files in a folder but not sub-folders. <code>DIR</code> enables you to list specific types of files (hidden, archive ready etc) and also only folders but I cannot see how to list only files.</p> <p>I need the following statement to return files for further processing, but folder names are messing...
56,274
898,377
2015-08-31 15:39:35
7,164,243
55
2011-08-23 16:20:13
97,869
2011-08-23 16:27:26
https://stackoverflow.com/q/7164184
https://stackoverflow.com/a/7164243
<p><code>dir /b /a-d</code> will give you files without directories. Note there is no space between <code>/a-d</code>. The '-' says "NOT" directories.</p> <p>From the <code>dir /?</code> help information:</p> <pre><code> /A Displays files with specified attributes. attributes D Directories ...
<p><code>dir /b /a-d</code> will give you files without directories. Note there is no space between <code>/a-d</code>. The '-' says "NOT" directories.</p> <p>From the <code>dir /?</code> help information:</p> <pre><code> /A Displays files with specified attributes. attributes D Directories ...
64, 2631
cmd, windows
<h1>Suppress directory names being listed with DIR</h1> <p>I want to list the files in a folder but not sub-folders. <code>DIR</code> enables you to list specific types of files (hidden, archive ready etc) and also only folders but I cannot see how to list only files.</p> <p>I need the following statement to return fi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,268
cmd
# Suppress directory names being listed with DIR I want to list the files in a folder but not sub-folders. `DIR` enables you to list specific types of files (hidden, archive ready etc) and also only folders but I cannot see how to list only files. I need the following statement to return files for further processing,...
`dir /b /a-d` will give you files without directories. Note there is no space between `/a-d`. The '-' says "NOT" directories. From the `dir /?` help information: ``` /A Displays files with specified attributes. attributes D Directories R Read-only files H Hidden files ...
4536376
generate backup file using date and time as filename
26
2010-12-27 02:58:31
<p>How do I do this properly. I'm trying to name the sql file that is being produced by mysqldump into the current date and time. I've already some research in this site and found a code in here: <a href="https://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format...
49,384
225,269
2020-09-20 01:40:32
4,631,046
55
2011-01-07 22:56:44
505,379
2012-05-15 22:00:18
https://stackoverflow.com/q/4536376
https://stackoverflow.com/a/4631046
<p>On Linux, simply put <code>$(date +%Y-%m-%d-%H.%M.%S)</code> to show date and time in the file name, so it looks like:</p> <pre><code>mysqldump -u &lt;user&gt; -p &lt;database&gt; | bzip2 -c &gt; &lt;backup&gt;$(date +%Y-%m-%d-%H.%M.%S).sql.bz2 </code></pre> <p>(This command also compresses the file using bzip2)</...
<p>On Linux, simply put <code>$(date +%Y-%m-%d-%H.%M.%S)</code> to show date and time in the file name, so it looks like:</p> <pre><code>mysqldump -u &lt;user&gt; -p &lt;database&gt; | bzip2 -c &gt; &lt;backup&gt;$(date +%Y-%m-%d-%H.%M.%S).sql.bz2 </code></pre> <p>(This command also compresses the file using bzip2)</...
21, 7002
batch-file, mysql
<h1>generate backup file using date and time as filename</h1> <p>How do I do this properly. I'm trying to name the sql file that is being produced by mysqldump into the current date and time. I've already some research in this site and found a code in here: <a href="https://stackoverflow.com/questions/203090/how-to-get...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,269
cmd
# generate backup file using date and time as filename How do I do this properly. I'm trying to name the sql file that is being produced by mysqldump into the current date and time. I've already some research in this site and found a code in here: [How to get current datetime on Windows command line, in a suitable for...
On Linux, simply put `$(date +%Y-%m-%d-%H.%M.%S)` to show date and time in the file name, so it looks like: ``` mysqldump -u <user> -p <database> | bzip2 -c > <backup>$(date +%Y-%m-%d-%H.%M.%S).sql.bz2 ``` (This command also compresses the file using bzip2)
19148907
How do I stop my batch file from printing the code it is running?
24
2013-10-03 00:21:42
<p>I have the following script:</p> <pre><code>FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) </code></pre> <p>I just wanted to print</p> <pre><code>1 2 3 </code></pre> <p>because I will be using the same logic a...
17,962
1,040,718
2022-07-26 11:20:40
19,149,079
55
2013-10-03 00:42:54
980,550
2022-07-26 11:20:40
https://stackoverflow.com/q/19148907
https://stackoverflow.com/a/19149079
<p>To avoid echoing the Windows commands in a batch file, use <code>@echo off</code>:</p> <pre><code>@ECHO OFF FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) </code></pre> <p>Note the preceding <code>@</code> in <cod...
<p>To avoid echoing the Windows commands in a batch file, use <code>@echo off</code>:</p> <pre><code>@ECHO OFF FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) </code></pre> <p>Note the preceding <code>@</code> in <cod...
64, 7002
batch-file, windows
<h1>How do I stop my batch file from printing the code it is running?</h1> <p>I have the following script:</p> <pre><code>FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) </code></pre> <p>I just wanted to print</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,270
cmd
# How do I stop my batch file from printing the code it is running? I have the following script: ``` FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) ``` I just wanted to print ``` 1 2 3 ``` because I will be usin...
To avoid echoing the Windows commands in a batch file, use `@echo off`: ``` @ECHO OFF FOR %%i IN (1 2 3) DO ( IF %%i==1 ( ECHO %%i ) IF %%i==2 ( ECHO %%i ) IF %%i==3 ( ECHO %%i ) ) ``` Note the preceding `@` in `echo off` prevents `echo off` from echoing. If you...
4176962
Recursively delete 0KB files using windows cmd
23
2010-11-14 09:42:07
<p>I have some process which creates some files of 0KB size in a directory and its sub-directories.<br> How can I delete the files from the file system using the windows command prompt?<br> Any single command or a script that will do the task will work. <hr/> I can only run simple cmd commands and scripts, working on a...
39,937
420,357
2024-11-29 04:17:50
4,177,169
55
2010-11-14 10:54:03
73,070
2010-11-14 10:54:03
https://stackoverflow.com/q/4176962
https://stackoverflow.com/a/4177169
<ol> <li><p>Iterate recursively over the files:</p> <pre><code>for /r %F in (*) </code></pre></li> <li><p>Find out zero-length files:</p> <pre><code>if %~zF==0 </code></pre></li> <li><p>Delete them:</p> <pre><code>del "%F" </code></pre></li> </ol> <p>Putting it all together:</p> <pre><code>for /r %F in (*) do if %...
<ol> <li><p>Iterate recursively over the files:</p> <pre><code>for /r %F in (*) </code></pre></li> <li><p>Find out zero-length files:</p> <pre><code>if %~zF==0 </code></pre></li> <li><p>Delete them:</p> <pre><code>del "%F" </code></pre></li> </ol> <p>Putting it all together:</p> <pre><code>for /r %F in (*) do if %...
64, 2631, 5310
cmd, file, windows
<h1>Recursively delete 0KB files using windows cmd</h1> <p>I have some process which creates some files of 0KB size in a directory and its sub-directories.<br> How can I delete the files from the file system using the windows command prompt?<br> Any single command or a script that will do the task will work. <hr/> I ca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,271
cmd
# Recursively delete 0KB files using windows cmd I have some process which creates some files of 0KB size in a directory and its sub-directories. How can I delete the files from the file system using the windows command prompt? Any single command or a script that will do the task will work. --- I can only run si...
1. Iterate recursively over the files: ``` for /r %F in (*) ``` 2. Find out zero-length files: ``` if %~zF==0 ``` 3. Delete them: ``` del "%F" ``` Putting it all together: ``` for /r %F in (*) do if %~zF==0 del "%F" ``` If you need this in a batch file, then you need to double the `%`: ...
16552479
Delete files in batch with without error message
59
2013-05-14 20:42:55
<p>I use the command </p> <pre><code>del "info*" </code></pre> <p>to delete a group of files starting with "info". The problem is that sometimes there is at least one of these files that exist,therefore they are deleted and others times no files exist and and error message happens. I need my script must not block ...
76,488
2,259,897
2015-07-07 17:51:41
16,552,624
54
2013-05-14 20:52:33
2,098,699
2013-05-14 20:52:33
https://stackoverflow.com/q/16552479
https://stackoverflow.com/a/16552624
<p>try this:</p> <pre><code>del "file to delete" &gt;nul 2&gt;&amp;1 del "info*" &gt;nul 2&gt;&amp;1 </code></pre> <p>This sends normal and error messages to <code>nul</code>.</p> <pre><code>del "file to delete" 2&gt;nul del "info*" 2&gt;nul </code></pre> <p>This sends only error messages to <code>nul</code>.</p>
<p>try this:</p> <pre><code>del "file to delete" &gt;nul 2&gt;&amp;1 del "info*" &gt;nul 2&gt;&amp;1 </code></pre> <p>This sends normal and error messages to <code>nul</code>.</p> <pre><code>del "file to delete" 2&gt;nul del "info*" 2&gt;nul </code></pre> <p>This sends only error messages to <code>nul</code>.</p>
7002, 37510
batch-file, delete-file
<h1>Delete files in batch with without error message</h1> <p>I use the command </p> <pre><code>del "info*" </code></pre> <p>to delete a group of files starting with "info". The problem is that sometimes there is at least one of these files that exist,therefore they are deleted and others times no files exist and an...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,272
cmd
# Delete files in batch with without error message I use the command ``` del "info*" ``` to delete a group of files starting with "info". The problem is that sometimes there is at least one of these files that exist,therefore they are deleted and others times no files exist and and error message happens. I need my s...
try this: ``` del "file to delete" >nul 2>&1 del "info*" >nul 2>&1 ``` This sends normal and error messages to `nul`. ``` del "file to delete" 2>nul del "info*" 2>nul ``` This sends only error messages to `nul`.
7516064
Escaping double-quote in `delims` option of `for /F`
39
2011-09-22 14:04:39
<p>I'm having a bit of trouble with a batch script which needs to parse a value out of an config file into a variable.</p> <p>Suitably anonymised, the relevant line of the file looks like </p> <pre><code>&lt;?define ProductShortName="Foo" ?&gt; </code></pre> <p>I want to set a variable to <code>Foo</code>. The strin...
58,341
573,420
2025-08-09 10:45:33
13,217,838
54
2012-11-04 10:43:29
589,059
2012-11-04 10:43:29
https://stackoverflow.com/q/7516064
https://stackoverflow.com/a/13217838
<p>You can use the double quotation mark as a delimiter with syntax like:</p> <pre><code>FOR /F delims^=^"^ tokens^=2 %G IN ('echo I "want" a "pony"') DO @ECHO %G </code></pre> <p>When run on the command line, using <code>tokens^=2</code> should give you <code>want</code>, and 4 tokens gets you a pony.</p> <p>Applyi...
<p>You can use the double quotation mark as a delimiter with syntax like:</p> <pre><code>FOR /F delims^=^"^ tokens^=2 %G IN ('echo I "want" a "pony"') DO @ECHO %G </code></pre> <p>When run on the command line, using <code>tokens^=2</code> should give you <code>want</code>, and 4 tokens gets you a pony.</p> <p>Applyi...
4804, 7002
batch-file, escaping
<h1>Escaping double-quote in `delims` option of `for /F`</h1> <p>I'm having a bit of trouble with a batch script which needs to parse a value out of an config file into a variable.</p> <p>Suitably anonymised, the relevant line of the file looks like </p> <pre><code>&lt;?define ProductShortName="Foo" ?&gt; </code></pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,273
cmd
# Escaping double-quote in `delims` option of `for /F` I'm having a bit of trouble with a batch script which needs to parse a value out of an config file into a variable. Suitably anonymised, the relevant line of the file looks like ``` <?define ProductShortName="Foo" ?> ``` I want to set a variable to `Foo`. The s...
You can use the double quotation mark as a delimiter with syntax like: ``` FOR /F delims^=^"^ tokens^=2 %G IN ('echo I "want" a "pony"') DO @ECHO %G ``` When run on the command line, using `tokens^=2` should give you `want`, and 4 tokens gets you a pony. Applying the technique to your original question, this should ...
10508778
PostBuildEvent Create Directory
36
2012-05-09 01:37:55
<p>I'm trying to create a folder named Design in the build output folder using th following commandline in the PostBuildEvent in visual studio</p> <pre><code>mkdir $(TargetDir)Design ....Runs Successfully but folder is not created mkdir "$(TargetDir)Design" ....Runs Successfully but folder is not created MD $(TargetD...
35,108
1,177,101
2019-07-16 14:47:00
26,621,578
54
2014-10-29 01:52:28
74,601
2014-10-29 01:52:28
https://stackoverflow.com/q/10508778
https://stackoverflow.com/a/26621578
<p>You need to do something like:</p> <pre><code>if not exist DirToCreate mkdir DirToCreate </code></pre>
<p>You need to do something like:</p> <pre><code>if not exist DirToCreate mkdir DirToCreate </code></pre>
9, 2631, 14456, 31225
c#, cmd, post-build-event, visual-studio-2010
<h1>PostBuildEvent Create Directory</h1> <p>I'm trying to create a folder named Design in the build output folder using th following commandline in the PostBuildEvent in visual studio</p> <pre><code>mkdir $(TargetDir)Design ....Runs Successfully but folder is not created mkdir "$(TargetDir)Design" ....Runs Successful...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,274
cmd
# PostBuildEvent Create Directory I'm trying to create a folder named Design in the build output folder using th following commandline in the PostBuildEvent in visual studio ``` mkdir $(TargetDir)Design ....Runs Successfully but folder is not created mkdir "$(TargetDir)Design" ....Runs Successfully but folder is not...
You need to do something like: ``` if not exist DirToCreate mkdir DirToCreate ```
25438172
find path of current folder - cmd
35
2014-08-22 01:04:53
<p>I use this script to find out the current folder with its .bat file:</p> <pre><code>for /f %%i in ("%0") do set curpath=%%~dpi echo %curpath% </code></pre> <p>it doesn't work correctly, if the path contains spaces(D:\Scripts\All Scripts -> retrieves only D:\Scripts\, if I place in the folder, whose path doesn't...
141,320
3,328,286
2017-04-28 08:11:45
25,440,709
54
2014-08-22 06:19:08
2,861,476
2017-04-28 08:11:45
https://stackoverflow.com/q/25438172
https://stackoverflow.com/a/25440709
<p><em>2015-03-30: Edited</em> - Missing information has been added</p> <p>To retrieve the current directory you can use the dynamic <code>%cd%</code> variable that holds the current active directory</p> <pre class="lang-dos prettyprint-override"><code>set "curpath=%cd%" </code></pre> <p>This generates a value with ...
<p><em>2015-03-30: Edited</em> - Missing information has been added</p> <p>To retrieve the current directory you can use the dynamic <code>%cd%</code> variable that holds the current active directory</p> <pre class="lang-dos prettyprint-override"><code>set "curpath=%cd%" </code></pre> <p>This generates a value with ...
2631
cmd
<h1>find path of current folder - cmd</h1> <p>I use this script to find out the current folder with its .bat file:</p> <pre><code>for /f %%i in ("%0") do set curpath=%%~dpi echo %curpath% </code></pre> <p>it doesn't work correctly, if the path contains spaces(D:\Scripts\All Scripts -> retrieves only D:\Scripts\, i...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,275
cmd
# find path of current folder - cmd I use this script to find out the current folder with its .bat file: ``` for /f %%i in ("%0") do set curpath=%%~dpi echo %curpath% ``` it doesn't work correctly, if the path contains spaces(D:\Scripts\All Scripts -> retrieves only D:\Scripts\, if I place in the folder, whose pat...
*2015-03-30: Edited* - Missing information has been added To retrieve the current directory you can use the dynamic `%cd%` variable that holds the current active directory ``` set "curpath=%cd%" ``` This generates a value with a ending backslash for the root directory, and without a backslash for the rest of directo...
26276348
echo json over command line into file
24
2014-10-09 10:40:42
<p>I have a build tool which is creating a <em>versions.json</em> file injected with a <code>json</code> format string.</p> <p>Initially I was thinking of just injecting the json via an echo, something like below.</p> <pre><code>json = {"commit_id": "b8f2b8b", "environment": "test", "tags_at_commit": "sometags", "pro...
68,039
846,381
2021-11-30 07:44:11
26,277,498
54
2014-10-09 11:39:54
2,262,272
2021-11-30 07:44:11
https://stackoverflow.com/q/26276348
https://stackoverflow.com/a/26277498
<p>To preserve double quotes you need to surround your variable in single quotes, like so:</p> <pre><code>json='{&quot;commit_id&quot;: &quot;b8f2b8b&quot;, &quot;environment&quot;: &quot;test&quot;, &quot;tags_at_commit&quot;: &quot;sometags&quot;, &quot;project&quot;: &quot;someproject&quot;, &quot;current_date&quot;...
<p>To preserve double quotes you need to surround your variable in single quotes, like so:</p> <pre><code>json='{&quot;commit_id&quot;: &quot;b8f2b8b&quot;, &quot;environment&quot;: &quot;test&quot;, &quot;tags_at_commit&quot;: &quot;sometags&quot;, &quot;project&quot;: &quot;someproject&quot;, &quot;current_date&quot;...
58, 1508, 2631, 13824
cmd, echo, json, linux
<h1>echo json over command line into file</h1> <p>I have a build tool which is creating a <em>versions.json</em> file injected with a <code>json</code> format string.</p> <p>Initially I was thinking of just injecting the json via an echo, something like below.</p> <pre><code>json = {"commit_id": "b8f2b8b", "environme...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,276
cmd
# echo json over command line into file I have a build tool which is creating a *versions.json* file injected with a `json` format string. Initially I was thinking of just injecting the json via an echo, something like below. ``` json = {"commit_id": "b8f2b8b", "environment": "test", "tags_at_commit": "sometags", "p...
To preserve double quotes you need to surround your variable in single quotes, like so: ``` json='{"commit_id": "b8f2b8b", "environment": "test", "tags_at_commit": "sometags", "project": "someproject", "current_date": "09/10/2014", "version": "someversion"}' echo "$json" > versions.json ``` Take into account that thi...
15428777
whats the difference between: %%a and %variable% variables?
21
2013-03-15 09:29:14
<pre><code>for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do ( set usemenu=a ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=b"') do ( set usemenu=b ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^...
121,990
2,010,401
2019-07-03 02:30:00
15,428,976
54
2013-03-15 09:40:22
73,070
2016-06-24 08:32:21
https://stackoverflow.com/q/15428777
https://stackoverflow.com/a/15428976
<p><code>%variable%</code> are <em>environment</em> variables. They are set with <code>set</code> and can be accessed with <code>%foo%</code> or <code>!foo!</code> (with delayed expansion if enabled). <code>%%a</code> are special variables created by the <code>for</code> command to represent the current loop item or a ...
<p><code>%variable%</code> are <em>environment</em> variables. They are set with <code>set</code> and can be accessed with <code>%foo%</code> or <code>!foo!</code> (with delayed expansion if enabled). <code>%%a</code> are special variables created by the <code>for</code> command to represent the current loop item or a ...
276, 2631, 7002
batch-file, cmd, variables
<h1>whats the difference between: %%a and %variable% variables?</h1> <pre><code>for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do ( set usemenu=a ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=b"') do ( set usemenu=b ) for /f "...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,277
cmd
# whats the difference between: %%a and %variable% variables? ``` for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=a"') do ( set usemenu=a ) for /f "tokens=*" %%a in ('find /v ":" "%appdata%\gamelauncher\options.txt" ^| find "menu=b"') do ( set usemenu=b ) for /f "tokens=*" %%a...
`%variable%` are *environment* variables. They are set with `set` and can be accessed with `%foo%` or `!foo!` (with delayed expansion if enabled). `%%a` are special variables created by the `for` command to represent the current loop item or a token of a current line. `for` is probably about the most complicated and p...
39527284
'module' object has no attribute 'py' when running from cmd
20
2016-09-16 08:49:24
<p>I'm currently learning unittesting, and I have stumbled upon a strange error:</p> <p>If I run my script from inside PyCharm, everything works perfectly. If I run it from my <code>cmd.exe</code> (as administrator), I get the following error:</p> <p><a href="https://i.sstatic.net/Q2oDm.png" rel="noreferrer"><img src...
12,928
6,063,416
2021-01-14 10:24:38
39,528,330
54
2016-09-16 09:42:50
2,492,624
2021-01-14 10:24:38
https://stackoverflow.com/q/39527284
https://stackoverflow.com/a/39528330
<p>Just remove the <code>.py</code> extension.</p> <p>You are running your tests using the <code>-m</code> command-line flag. The Python documentation will tell you more about it, just check out this <a href="http://docs.python.org/2/using/cmdline.html#cmdoption-m" rel="noreferrer">link</a>.</p> <p>In a word, the <code...
<p>Just remove the <code>.py</code> extension.</p> <p>You are running your tests using the <code>-m</code> command-line flag. The Python documentation will tell you more about it, just check out this <a href="http://docs.python.org/2/using/cmdline.html#cmdoption-m" rel="noreferrer">link</a>.</p> <p>In a word, the <code...
16, 1931, 2631
cmd, python, unit-testing
<h1>'module' object has no attribute 'py' when running from cmd</h1> <p>I'm currently learning unittesting, and I have stumbled upon a strange error:</p> <p>If I run my script from inside PyCharm, everything works perfectly. If I run it from my <code>cmd.exe</code> (as administrator), I get the following error:</p> <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,278
cmd
# 'module' object has no attribute 'py' when running from cmd I'm currently learning unittesting, and I have stumbled upon a strange error: If I run my script from inside PyCharm, everything works perfectly. If I run it from my `cmd.exe` (as administrator), I get the following error: [![enter image description here]...
Just remove the `.py` extension. You are running your tests using the `-m` command-line flag. The Python documentation will tell you more about it, just check out this [link](http://docs.python.org/2/using/cmdline.html#cmdoption-m). In a word, the `-m` option let you run a module, in your case the `unittest` module. ...
130116
Windows batch command(s) to read first line from text file
102
2008-09-24 21:33:27
<p>How can I read the first line from a text file using a Windows batch file? Since the file is large I only want to deal with the first line.</p>
399,491
9,822
2023-01-27 11:31:06
130,298
53
2008-09-24 22:20:14
19,719
2012-08-28 19:50:48
https://stackoverflow.com/q/130116
https://stackoverflow.com/a/130298
<p>Here's a general-purpose batch file to print the top <code>n</code> lines from a file like the GNU <code>head</code> utility, instead of just a single line.</p> <pre><code>@echo off if [%1] == [] goto usage if [%2] == [] goto usage call :print_head %1 %2 goto :eof REM REM print_head REM Prints the first non-blan...
<p>Here's a general-purpose batch file to print the top <code>n</code> lines from a file like the GNU <code>head</code> utility, instead of just a single line.</p> <pre><code>@echo off if [%1] == [] goto usage if [%2] == [] goto usage call :print_head %1 %2 goto :eof REM REM print_head REM Prints the first non-blan...
2631, 7002
batch-file, cmd
<h1>Windows batch command(s) to read first line from text file</h1> <p>How can I read the first line from a text file using a Windows batch file? Since the file is large I only want to deal with the first line.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,280
cmd
# Windows batch command(s) to read first line from text file How can I read the first line from a text file using a Windows batch file? Since the file is large I only want to deal with the first line.
Here's a general-purpose batch file to print the top `n` lines from a file like the GNU `head` utility, instead of just a single line. ``` @echo off if [%1] == [] goto usage if [%2] == [] goto usage call :print_head %1 %2 goto :eof REM REM print_head REM Prints the first non-blank %1 lines in the file %2. REM :prin...
14691494
check if command was successful in a batch file
68
2013-02-04 16:55:46
<p>How within a batch file to check if command</p> <pre><code>start "" javaw -jar %~p0/example.jar </code></pre> <p>was successful or produced an error?</p> <p>I want to use if/else statements to echo this info out.</p>
174,532
1,913,629
2022-07-13 17:58:23
14,691,533
53
2013-02-04 16:57:15
73,070
2020-04-15 13:15:43
https://stackoverflow.com/q/14691494
https://stackoverflow.com/a/14691533
<p>You can use</p> <pre><code>if errorlevel 1 echo Unsuccessful </code></pre> <p>in some cases. This depends on the last command returning a proper exit code. You won't be able to tell that there is anything wrong if your program returns normally even if there was an abnormal condition.</p> <p>Caution with programs ...
<p>You can use</p> <pre><code>if errorlevel 1 echo Unsuccessful </code></pre> <p>in some cases. This depends on the last command returning a proper exit code. You won't be able to tell that there is anything wrong if your program returns normally even if there was an abnormal condition.</p> <p>Caution with programs ...
7002, 10021, 17564
batch-file, errorlevel, exit-code
<h1>check if command was successful in a batch file</h1> <p>How within a batch file to check if command</p> <pre><code>start "" javaw -jar %~p0/example.jar </code></pre> <p>was successful or produced an error?</p> <p>I want to use if/else statements to echo this info out.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,281
cmd
# check if command was successful in a batch file How within a batch file to check if command ``` start "" javaw -jar %~p0/example.jar ``` was successful or produced an error? I want to use if/else statements to echo this info out.
You can use ``` if errorlevel 1 echo Unsuccessful ``` in some cases. This depends on the last command returning a proper exit code. You won't be able to tell that there is anything wrong if your program returns normally even if there was an abnormal condition. Caution with programs like Robocopy, which require a mor...
15423
How to change the icon of .bat file programmatically?
54
2008-08-19 00:21:12
<p>I'd like to know what's the way to actually set the icon of a <code>.bat</code> file to an arbitrary icon. How would I go about doing that programmatically, independently of the language I may be using.</p>
284,374
883
2024-09-27 14:44:38
15,437
53
2008-08-19 00:37:11
1,600
2016-08-16 18:11:04
https://stackoverflow.com/q/15423
https://stackoverflow.com/a/15437
<p>Assuming you're referring to MS-DOS batch files: as it is simply a text file with a special extension, a <code>.bat</code> file doesn't store an icon of its own.</p> <p>You can, however, create a shortcut in the <code>.lnk</code> format that stores an icon.</p>
<p>Assuming you're referring to MS-DOS batch files: as it is simply a text file with a special extension, a <code>.bat</code> file doesn't store an icon of its own.</p> <p>You can, however, create a shortcut in the <code>.lnk</code> format that stores an icon.</p>
64, 1004, 7002
batch-file, icons, windows
<h1>How to change the icon of .bat file programmatically?</h1> <p>I'd like to know what's the way to actually set the icon of a <code>.bat</code> file to an arbitrary icon. How would I go about doing that programmatically, independently of the language I may be using.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,282
cmd
# How to change the icon of .bat file programmatically? I'd like to know what's the way to actually set the icon of a `.bat` file to an arbitrary icon. How would I go about doing that programmatically, independently of the language I may be using.
Assuming you're referring to MS-DOS batch files: as it is simply a text file with a special extension, a `.bat` file doesn't store an icon of its own. You can, however, create a shortcut in the `.lnk` format that stores an icon.
4367930
ERRORLEVEL inside IF
44
2010-12-06 15:27:19
<p>Just stumbled into a weird thing with <code>%ERRORLEVEL%</code> and wanted to see if anyone knows why and if there's a way to fix it. Essentially, it seems as if commands executed inside if statements don't set the <code>%ERRORLEVEL%</code> variable. The <code>ERRORLEVEL</code> (as in <code>IF ERRORLEVEL 1</code>, w...
36,336
56,699
2024-09-29 09:16:16
4,368,104
53
2010-12-06 15:45:53
145,364
2010-12-06 15:45:53
https://stackoverflow.com/q/4367930
https://stackoverflow.com/a/4368104
<p>Try using <code>setlocal enabledelayedexpansion</code> at the start of your batch file, and <code>!ERRORLEVEL!</code> inside your <code>IF</code>. This seems to work for me:</p> <pre><code>@echo off setlocal enabledelayedexpansion dir nul echo %ERRORLEVEL% if .1.==.1. ( urklbkrlksdj - not a command echo %ERROR...
<p>Try using <code>setlocal enabledelayedexpansion</code> at the start of your batch file, and <code>!ERRORLEVEL!</code> inside your <code>IF</code>. This seems to work for me:</p> <pre><code>@echo off setlocal enabledelayedexpansion dir nul echo %ERRORLEVEL% if .1.==.1. ( urklbkrlksdj - not a command echo %ERROR...
7002, 17564
batch-file, errorlevel
<h1>ERRORLEVEL inside IF</h1> <p>Just stumbled into a weird thing with <code>%ERRORLEVEL%</code> and wanted to see if anyone knows why and if there's a way to fix it. Essentially, it seems as if commands executed inside if statements don't set the <code>%ERRORLEVEL%</code> variable. The <code>ERRORLEVEL</code> (as in <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,283
cmd
# ERRORLEVEL inside IF Just stumbled into a weird thing with `%ERRORLEVEL%` and wanted to see if anyone knows why and if there's a way to fix it. Essentially, it seems as if commands executed inside if statements don't set the `%ERRORLEVEL%` variable. The `ERRORLEVEL` (as in `IF ERRORLEVEL 1`, which is different from ...
Try using `setlocal enabledelayedexpansion` at the start of your batch file, and `!ERRORLEVEL!` inside your `IF`. This seems to work for me: ``` @echo off setlocal enabledelayedexpansion dir nul echo %ERRORLEVEL% if .1.==.1. ( urklbkrlksdj - not a command echo %ERRORLEVEL% echo !ERRORLEVEL! ) ```
12273866
Is there a way to redirect ONLY stderr to stdout (not combine the two) so it can be piped to other programs?
35
2012-09-05 02:47:50
<p>I'm working in a Windows <code>CMD.EXE</code> environment and would like to change the output of <code>stdout</code> to match that of <code>stderr</code> so that I can pipe error messages to other programs without the intermediary of a file.</p> <p>I'm aware of the <code>2&gt;&amp;1</code> notation, but that combin...
17,029
1,530,402
2015-10-09 21:17:49
12,274,145
53
2012-09-05 03:34:09
1,012,053
2013-11-08 18:38:42
https://stackoverflow.com/q/12273866
https://stackoverflow.com/a/12274145
<p>Interesting question :-)</p> <p>CMD processes redirection from left to right. You want to first redirect 2 (stderr) to &amp;1 (stdout), then redirect 1 (stdout) to something else. At this point stderr will still be redirected to the previous definition of stdout. The pipe will still work with the old definition of ...
<p>Interesting question :-)</p> <p>CMD processes redirection from left to right. You want to first redirect 2 (stderr) to &amp;1 (stdout), then redirect 1 (stdout) to something else. At this point stderr will still be redirected to the previous definition of stdout. The pipe will still work with the old definition of ...
64, 7002
batch-file, windows
<h1>Is there a way to redirect ONLY stderr to stdout (not combine the two) so it can be piped to other programs?</h1> <p>I'm working in a Windows <code>CMD.EXE</code> environment and would like to change the output of <code>stdout</code> to match that of <code>stderr</code> so that I can pipe error messages to other pr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,284
cmd
# Is there a way to redirect ONLY stderr to stdout (not combine the two) so it can be piped to other programs? I'm working in a Windows `CMD.EXE` environment and would like to change the output of `stdout` to match that of `stderr` so that I can pipe error messages to other programs without the intermediary of a file....
Interesting question :-) CMD processes redirection from left to right. You want to first redirect 2 (stderr) to &1 (stdout), then redirect 1 (stdout) to something else. At this point stderr will still be redirected to the previous definition of stdout. The pipe will still work with the old definition of stdout (which ...
6257948
Copy a list (txt) of files
31
2011-06-06 20:56:26
<p>I've seen some scripts examples over SO, but none of them seems to provide examples of how to read filenames from a .txt list.</p> <p>This example is good, so as to copy all files from A to B folder</p> <pre><code>xcopy c:\olddir\*.java c:\newdir /D /E /Q /Y </code></pre> <p>But I need something like the next, wh...
94,037
285,983
2021-07-28 17:15:32
6,258,198
53
2011-06-06 21:24:48
152,522
2017-05-11 14:06:44
https://stackoverflow.com/q/6257948
https://stackoverflow.com/a/6258198
<p>Given your list of file names in a file called <code>File-list.txt</code>, the following lines should do what you want:</p> <pre><code>@echo off set src_folder=c:\whatever set dst_folder=c:\target for /f "tokens=*" %%i in (File-list.txt) DO ( xcopy /S/E "%src_folder%\%%i" "%dst_folder%" ) </code></pre>
<p>Given your list of file names in a file called <code>File-list.txt</code>, the following lines should do what you want:</p> <pre><code>@echo off set src_folder=c:\whatever set dst_folder=c:\target for /f "tokens=*" %%i in (File-list.txt) DO ( xcopy /S/E "%src_folder%\%%i" "%dst_folder%" ) </code></pre>
3635, 7002
batch-file, scripting-language
<h1>Copy a list (txt) of files</h1> <p>I've seen some scripts examples over SO, but none of them seems to provide examples of how to read filenames from a .txt list.</p> <p>This example is good, so as to copy all files from A to B folder</p> <pre><code>xcopy c:\olddir\*.java c:\newdir /D /E /Q /Y </code></pre> <p>Bu...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,285
cmd
# Copy a list (txt) of files I've seen some scripts examples over SO, but none of them seems to provide examples of how to read filenames from a .txt list. This example is good, so as to copy all files from A to B folder ``` xcopy c:\olddir\*.java c:\newdir /D /E /Q /Y ``` But I need something like the next, where ...
Given your list of file names in a file called `File-list.txt`, the following lines should do what you want: ``` @echo off set src_folder=c:\whatever set dst_folder=c:\target for /f "tokens=*" %%i in (File-list.txt) DO ( xcopy /S/E "%src_folder%\%%i" "%dst_folder%" ) ```
14786623
Batch file Copy using %1 for drag and drop
25
2013-02-09 09:18:53
<p>I tried to make a drag-and-drop batch file.</p> <p>I have the problem that a file exists but the batch file couldn't find it...</p> <p>I want to copy <code>.png</code> files (like <code>pict_2013020808172137243.png</code>) to another folder and rename it.</p> <p>In the path are symbols like <code>_</code> and spa...
77,559
2,056,750
2021-03-29 06:24:35
14,787,643
53
2013-02-09 11:29:44
463,115
2021-03-29 06:24:35
https://stackoverflow.com/q/14786623
https://stackoverflow.com/a/14787643
<p>Drag &amp; drop is badly implemented for batch files.<br /> The names are quoted, if a space is present, but not if a special character is found, like <code>&amp;,;^</code></p> <p>For spaces only in your filenames, you need to change your code only a bit.</p> <pre><code>@ECHO OFF ECHO &quot;%~1&quot; COPY &quot;%~1&...
<p>Drag &amp; drop is badly implemented for batch files.<br /> The names are quoted, if a space is present, but not if a special character is found, like <code>&amp;,;^</code></p> <p>For spaces only in your filenames, you need to change your code only a bit.</p> <pre><code>@ECHO OFF ECHO &quot;%~1&quot; COPY &quot;%~1&...
360, 2833, 4330, 6268, 7002
batch-file, copy, drag-and-drop, parameters, path
<h1>Batch file Copy using %1 for drag and drop</h1> <p>I tried to make a drag-and-drop batch file.</p> <p>I have the problem that a file exists but the batch file couldn't find it...</p> <p>I want to copy <code>.png</code> files (like <code>pict_2013020808172137243.png</code>) to another folder and rename it.</p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,286
cmd
# Batch file Copy using %1 for drag and drop I tried to make a drag-and-drop batch file. I have the problem that a file exists but the batch file couldn't find it... I want to copy `.png` files (like `pict_2013020808172137243.png`) to another folder and rename it. In the path are symbols like `_` and spaces, also I...
Drag & drop is badly implemented for batch files. The names are quoted, if a space is present, but not if a special character is found, like `&,;^` For spaces only in your filenames, you need to change your code only a bit. ``` @ECHO OFF ECHO "%~1" COPY "%~1" "%CD%\test\" /Y /S MOVE "%CD%\mob\*.png" "%CD%\test\tes...
664957
Can I mask an input text in a bat file?
113
2009-03-20 04:14:00
<p>I am writing a batch file to execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text? I don't need to print ******* characters instead of input characters. Linux's Password prompt behavior (Print nothing while typing) is enough. </p> <pre><code>@echo off...
264,052
76,465
2024-10-24 16:51:33
665,191
52
2009-03-20 06:40:11
14,860
2016-12-30 01:16:48
https://stackoverflow.com/q/664957
https://stackoverflow.com/a/665191
<p>Up to XP and Server 2003, you can make use of another included tool (VBScript) - the following two scripts do the job you want.</p> <p>First, <code>getpwd.cmd</code>:</p> <pre><code>@echo off &lt;nul: set /p passwd=Password: for /f "delims=" %%i in ('cscript /nologo getpwd.vbs') do set passwd=%%i echo. </code></p...
<p>Up to XP and Server 2003, you can make use of another included tool (VBScript) - the following two scripts do the job you want.</p> <p>First, <code>getpwd.cmd</code>:</p> <pre><code>@echo off &lt;nul: set /p passwd=Password: for /f "delims=" %%i in ('cscript /nologo getpwd.vbs') do set passwd=%%i echo. </code></p...
2631, 7002, 9938
batch-file, cmd, command-prompt
<h1>Can I mask an input text in a bat file?</h1> <p>I am writing a batch file to execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text? I don't need to print ******* characters instead of input characters. Linux's Password prompt behavior (Print nothing whil...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,287
cmd
# Can I mask an input text in a bat file? I am writing a batch file to execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text? I don't need to print ******* characters instead of input characters. Linux's Password prompt behavior (Print nothing while typing)...
Up to XP and Server 2003, you can make use of another included tool (VBScript) - the following two scripts do the job you want. First, `getpwd.cmd`: ``` @echo off <nul: set /p passwd=Password: for /f "delims=" %%i in ('cscript /nologo getpwd.vbs') do set passwd=%%i echo. ``` Then, `getpwd.vbs`: ``` Set oScriptPW =...
9922498
Calculate time difference in Windows batch file
60
2012-03-29 09:21:39
<p>How can I get the difference between two times in a Batch file? Because I want to print it in an HTML file.</p> <p>I thought this would be possible, but it isn't.</p> <pre><code>Set "tijd=%time%" echo %tijd% echo %time%-%tijd% </code></pre> <p>Results:</p> <pre><code>11:07:48,85 11:16:58,99-11:07:48,85 </code></...
143,996
1,259,558
2024-03-09 00:49:01
9,938,411
52
2012-03-30 07:05:07
1,259,558
2023-05-09 09:26:35
https://stackoverflow.com/q/9922498
https://stackoverflow.com/a/9938411
<p>As answered here: <a href="https://stackoverflow.com/questions/4487100/how-can-i-use-a-windows-batch-file-to-measure-the-performance-of-console-applica">How can I use a Windows batch file to measure the performance of console application?</a></p> <p>Below batch &quot;program&quot; should do what you want. Please not...
<p>As answered here: <a href="https://stackoverflow.com/questions/4487100/how-can-i-use-a-windows-batch-file-to-measure-the-performance-of-console-applica">How can I use a Windows batch file to measure the performance of console application?</a></p> <p>Below batch &quot;program&quot; should do what you want. Please not...
64, 603, 7002
batch-file, time, windows
<h1>Calculate time difference in Windows batch file</h1> <p>How can I get the difference between two times in a Batch file? Because I want to print it in an HTML file.</p> <p>I thought this would be possible, but it isn't.</p> <pre><code>Set "tijd=%time%" echo %tijd% echo %time%-%tijd% </code></pre> <p>Results:</p> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,288
cmd
# Calculate time difference in Windows batch file How can I get the difference between two times in a Batch file? Because I want to print it in an HTML file. I thought this would be possible, but it isn't. ``` Set "tijd=%time%" echo %tijd% echo %time%-%tijd% ``` Results: ``` 11:07:48,85 11:16:58,99-11:07:48,85 ```...
As answered here: [How can I use a Windows batch file to measure the performance of console application?](https://stackoverflow.com/questions/4487100/how-can-i-use-a-windows-batch-file-to-measure-the-performance-of-console-applica) Below batch "program" should do what you want. Please note that it outputs the data in ...
44907377
What is "epoch" in keras.models.Model.fit?
51
2017-07-04 13:30:34
<p>What is "epoch" in <code>keras.models.Model.fit</code>? Is it one gradient update? If it is more than one gradient update, then what is defining an epoch?</p> <p>Suppose I am feeding my own batches to <code>fit</code>. I would regard "epoch" as finishing to process entire training set (is this correct)? Then how to...
47,815
258,483
2017-07-04 13:45:24
44,907,684
52
2017-07-04 13:45:24
5,215,538
2017-07-04 13:45:24
https://stackoverflow.com/q/44907377
https://stackoverflow.com/a/44907684
<p>Here is how Keras <a href="https://keras.io/getting-started/faq/#what-does-sample-batch-epoch-mean" rel="noreferrer">documentation</a> defines an epoch:</p> <blockquote> <p><strong>Epoch</strong>: an arbitrary cutoff, generally defined as "one pass over the entire dataset", used to separate training into distinct...
<p>Here is how Keras <a href="https://keras.io/getting-started/faq/#what-does-sample-batch-epoch-mean" rel="noreferrer">documentation</a> defines an epoch:</p> <blockquote> <p><strong>Epoch</strong>: an arbitrary cutoff, generally defined as "one pass over the entire dataset", used to separate training into distinct...
5990, 30645, 112144
batch-processing, keras, machine-learning
<h1>What is "epoch" in keras.models.Model.fit?</h1> <p>What is "epoch" in <code>keras.models.Model.fit</code>? Is it one gradient update? If it is more than one gradient update, then what is defining an epoch?</p> <p>Suppose I am feeding my own batches to <code>fit</code>. I would regard "epoch" as finishing to proces...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,289
cmd
# What is "epoch" in keras.models.Model.fit? What is "epoch" in `keras.models.Model.fit`? Is it one gradient update? If it is more than one gradient update, then what is defining an epoch? Suppose I am feeding my own batches to `fit`. I would regard "epoch" as finishing to process entire training set (is this correct...
Here is how Keras [documentation](https://keras.io/getting-started/faq/#what-does-sample-batch-epoch-mean) defines an epoch: > **Epoch**: an arbitrary cutoff, generally defined as "one pass over the entire dataset", used to separate training into distinct phases, which is useful for logging and periodic evaluation. S...
23041983
Path prefixes \??\ and \\?\
43
2014-04-13 11:10:10
<p>What is the difference between paths prefixed with <code>\??\</code> and those prefixed with <code>\\?\</code> </p> <p>At Windows 7 CMD-Line </p> <ul> <li>DIR gives: <code>\??\Volume{00000000-0000-0000-0000-000000000000}\</code> ...
19,845
3,518,601
2023-10-02 09:55:45
46,019,856
52
2017-09-03 02:51:39
205,580
2023-10-02 09:55:45
https://stackoverflow.com/q/23041983
https://stackoverflow.com/a/46019856
<p>In NT, <code>\??\</code> is a path prefix that stands for the object directory that's reserved for devices, or more specifically, device aliases (made available to the Win32 subsystem/personality). A device alias is implemented in the object namespace as a symbolic link (not to be confused with the file system entit...
<p>In NT, <code>\??\</code> is a path prefix that stands for the object directory that's reserved for devices, or more specifically, device aliases (made available to the Win32 subsystem/personality). A device alias is implemented in the object namespace as a symbolic link (not to be confused with the file system entit...
64, 889, 2631, 7002
batch-file, cmd, winapi, windows
<h1>Path prefixes \??\ and \\?\</h1> <p>What is the difference between paths prefixed with <code>\??\</code> and those prefixed with <code>\\?\</code> </p> <p>At Windows 7 CMD-Line </p> <ul> <li>DIR gives: <code>\??\Volume{00000000-00...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,290
cmd
# Path prefixes \??\ and \\?\ What is the difference between paths prefixed with `\??\` and those prefixed with `\\?\` At Windows 7 CMD-Line - DIR gives: `\??\Volume{00000000-0000-0000-0000-000000000000}\` - WMIC VOLUME LIST gives `\\?\Volume{00000000-0000-0000-0000-000000000000}\` Thanks Additional Information: ...
In NT, `\??\` is a path prefix that stands for the object directory that's reserved for devices, or more specifically, device aliases (made available to the Win32 subsystem/personality). A device alias is implemented in the object namespace as a symbolic link (not to be confused with the file system entity of the same ...
40041334
Difference between Step, Tasklet and Chunk in Spring Batch
34
2016-10-14 10:48:43
<p>What is the difference between Step, Tasklet and Chunk in spring batch.? </p> <p>Also, How to execute step in parallel via Spring Batch. ?</p>
38,418
5,101,474
2019-11-12 08:03:29
40,043,950
52
2016-10-14 13:06:09
5,190,019
2016-10-14 13:06:09
https://stackoverflow.com/q/40041334
https://stackoverflow.com/a/40043950
<p>Well that's actually a good question. Here's an example of configuration:</p> <pre><code>&lt;job id="sampleJob" job-repository="jobRepository"&gt; &lt;step id="step1" next="step2"&gt; &lt;tasklet transaction-manager="transactionManager"&gt; &lt;chunk reader="itemReader" writer="itemWriter" c...
<p>Well that's actually a good question. Here's an example of configuration:</p> <pre><code>&lt;job id="sampleJob" job-repository="jobRepository"&gt; &lt;step id="step1" next="step2"&gt; &lt;tasklet transaction-manager="transactionManager"&gt; &lt;chunk reader="itemReader" writer="itemWriter" c...
1211, 41895
spring, spring-batch
<h1>Difference between Step, Tasklet and Chunk in Spring Batch</h1> <p>What is the difference between Step, Tasklet and Chunk in spring batch.? </p> <p>Also, How to execute step in parallel via Spring Batch. ?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,291
cmd
# Difference between Step, Tasklet and Chunk in Spring Batch What is the difference between Step, Tasklet and Chunk in spring batch.? Also, How to execute step in parallel via Spring Batch. ?
Well that's actually a good question. Here's an example of configuration: ``` <job id="sampleJob" job-repository="jobRepository"> <step id="step1" next="step2"> <tasklet transaction-manager="transactionManager"> <chunk reader="itemReader" writer="itemWriter" commit-interval="10"/> </tas...
29113456
wget not recognized as internal or external command
34
2015-03-18 03:05:17
<p>I am working on a program to auto update my game as I make new developments and add new patches. When I go to run the patch update it doesn't recognize wget as a internal or external command. Game:</p> <pre><code>:Checkforupdates cls cd C:\AirlineSim\ echo Checking for Updates wget "http://intervers...
232,105
4,683,430
2023-01-20 15:54:59
29,113,634
52
2015-03-18 03:26:32
2,544,158
2020-11-23 14:14:11
https://stackoverflow.com/q/29113456
https://stackoverflow.com/a/29113634
<p><code>wget</code> is a third-party program that doesn't come bundled with Windows, so you need to explicitly install it in order to use it.</p> <p>You can find (one of) the Windows versions here: <a href="http://gnuwin32.sourceforge.net/packages/wget.htm" rel="noreferrer">http://gnuwin32.sourceforge.net/packages/wge...
<p><code>wget</code> is a third-party program that doesn't come bundled with Windows, so you need to explicitly install it in order to use it.</p> <p>You can find (one of) the Windows versions here: <a href="http://gnuwin32.sourceforge.net/packages/wget.htm" rel="noreferrer">http://gnuwin32.sourceforge.net/packages/wge...
5583, 7002, 34615
batch-file, downloading-website-files, wget
<h1>wget not recognized as internal or external command</h1> <p>I am working on a program to auto update my game as I make new developments and add new patches. When I go to run the patch update it doesn't recognize wget as a internal or external command. Game:</p> <pre><code>:Checkforupdates cls cd C:\Airline...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,292
cmd
# wget not recognized as internal or external command I am working on a program to auto update my game as I make new developments and add new patches. When I go to run the patch update it doesn't recognize wget as a internal or external command. Game: ``` :Checkforupdates cls cd C:\AirlineSim\ echo Checki...
`wget` is a third-party program that doesn't come bundled with Windows, so you need to explicitly install it in order to use it. You can find (one of) the Windows versions here: <http://gnuwin32.sourceforge.net/packages/wget.htm> You will need to add the path of the `wget.exe` file to your `PATH` environment variable...
8648178
Getting substring of a token in for loop?
33
2011-12-27 18:53:43
<p>I have this <code>for</code> loop to get a list of directory names:</p> <pre><code>for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) do ( echo %%g ) </code></pre> <p>Output:</p> <pre><code>C:\WINDOWS\Assembly\gac_msil\policy.5.0.A.D C:\WINDOWS\Assembly\gac_msil\policy.5.0.A.D.O C:\WINDOWS\Assembly\gac_msil\...
32,180
310,767
2021-01-26 16:07:41
8,648,385
52
2011-12-27 19:20:54
778,560
2011-12-27 19:20:54
https://stackoverflow.com/q/8648178
https://stackoverflow.com/a/8648385
<p>Of course that <code>set x=%%g</code> and a substring extraction of x should work, but be aware that if the substring is taken <em>inside a FOR loop</em>, it must be done with ! instead of % (Delayed Expansion):</p> <pre><code>setlocal EnableDelayedExpansion for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) d...
<p>Of course that <code>set x=%%g</code> and a substring extraction of x should work, but be aware that if the substring is taken <em>inside a FOR loop</em>, it must be done with ! instead of % (Delayed Expansion):</p> <pre><code>setlocal EnableDelayedExpansion for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) d...
139, 2531, 7002, 10946
batch-file, for-loop, string, token
<h1>Getting substring of a token in for loop?</h1> <p>I have this <code>for</code> loop to get a list of directory names:</p> <pre><code>for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) do ( echo %%g ) </code></pre> <p>Output:</p> <pre><code>C:\WINDOWS\Assembly\gac_msil\policy.5.0.A.D C:\WINDOWS\Assembly\gac_...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,293
cmd
# Getting substring of a token in for loop? I have this `for` loop to get a list of directory names: ``` for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) do ( echo %%g ) ``` Output: ``` C:\WINDOWS\Assembly\gac_msil\policy.5.0.A.D C:\WINDOWS\Assembly\gac_msil\policy.5.0.A.D.O C:\WINDOWS\Assembly\gac_msil\poli...
Of course that `set x=%%g` and a substring extraction of x should work, but be aware that if the substring is taken *inside a FOR loop*, it must be done with ! instead of % (Delayed Expansion): ``` setlocal EnableDelayedExpansion for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) do ( set x=%%g echo !x:~29! ) ```
16589846
How to overwrite a text file from a batch file
30
2013-05-16 14:15:12
<p>I am aware you can append to the end of a file with batch like so...</p> <pre><code>echo I like turtles &gt;&gt; file.txt </code></pre> <p>but I would like to overwrite the file instead. How could this be done?</p>
31,499
410,072
2016-01-21 07:44:01
16,589,929
52
2013-05-16 14:18:56
410,072
2013-05-16 14:38:23
https://stackoverflow.com/q/16589846
https://stackoverflow.com/a/16589929
<p>Just answered my own question, this works:</p> <pre><code>echo I like turtles &gt; file.txt ^ | Just one of these </code></pre>
<p>Just answered my own question, this works:</p> <pre><code>echo I like turtles &gt; file.txt ^ | Just one of these </code></pre>
5370, 7002
batch-file, dos
<h1>How to overwrite a text file from a batch file</h1> <p>I am aware you can append to the end of a file with batch like so...</p> <pre><code>echo I like turtles &gt;&gt; file.txt </code></pre> <p>but I would like to overwrite the file instead. How could this be done?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,294
cmd
# How to overwrite a text file from a batch file I am aware you can append to the end of a file with batch like so... ``` echo I like turtles >> file.txt ``` but I would like to overwrite the file instead. How could this be done?
Just answered my own question, this works: ``` echo I like turtles > file.txt ^ | Just one of these ```
9430642
Win bat file: How to add leading zeros to a variable in a for loop?
23
2012-02-24 12:18:21
<p>Very simple, I guess... I need to get a usable variable by adding leading zeros to the loop index variable (%%i) below. </p> <pre><code>@echo off for /L %%i in (1, 1, 5) do ( echo %%i rem How to create a variable j here as a rem result of adding leading zeros to %%i? (001, 002, 003 etc.) )...
46,842
146,400
2017-05-05 23:19:44
9,430,912
52
2012-02-24 12:37:58
463,115
2017-05-05 23:19:44
https://stackoverflow.com/q/9430642
https://stackoverflow.com/a/9430912
<p>Prefix the string with zeros and then take the desired count of characters from the right side:</p> <pre><code>@echo off set count=5 setlocal EnableDelayedExpansion for /L %%i in (1, 1, %count%) do ( set "formattedValue=000000%%i" echo !formattedValue:~-3! ) </code></pre> <p>Outputs:</p> <pre><code>001...
<p>Prefix the string with zeros and then take the desired count of characters from the right side:</p> <pre><code>@echo off set count=5 setlocal EnableDelayedExpansion for /L %%i in (1, 1, %count%) do ( set "formattedValue=000000%%i" echo !formattedValue:~-3! ) </code></pre> <p>Outputs:</p> <pre><code>001...
64, 2314, 7002
batch-file, loops, windows
<h1>Win bat file: How to add leading zeros to a variable in a for loop?</h1> <p>Very simple, I guess... I need to get a usable variable by adding leading zeros to the loop index variable (%%i) below. </p> <pre><code>@echo off for /L %%i in (1, 1, 5) do ( echo %%i rem How to create a variable j here as a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,295
cmd
# Win bat file: How to add leading zeros to a variable in a for loop? Very simple, I guess... I need to get a usable variable by adding leading zeros to the loop index variable (%%i) below. ``` @echo off for /L %%i in (1, 1, 5) do ( echo %%i rem How to create a variable j here as a rem result...
Prefix the string with zeros and then take the desired count of characters from the right side: ``` @echo off set count=5 setlocal EnableDelayedExpansion for /L %%i in (1, 1, %count%) do ( set "formattedValue=000000%%i" echo !formattedValue:~-3! ) ``` Outputs: ``` 001 002 003 004 005 ```
44281617
Why do text/commands become invisible when I use Git log?
17
2017-05-31 09:59:17
<p>I have problems with using Git. Everything works fine when running on CMD and the <code>$</code> shows up and my text shows up. But when I go to my <code>git log</code> my text suddenly disappears. It's just a <code>:</code> and I can type commands but not see them.</p> <p>When I go out from the <code>git log</code>...
10,382
8,086,058
2025-03-01 05:35:52
47,384,104
52
2017-11-20 02:02:29
1,465,593
2025-03-01 05:33:56
https://stackoverflow.com/q/44281617
https://stackoverflow.com/a/47384104
<p>I had this problem after exiting <code>git log</code> in Windows Git Bash.</p> <p>I fixed it by resetting the terminal using <code>reset</code>.</p>
<p>I had this problem after exiting <code>git log</code> in Windows Git Bash.</p> <p>I fixed it by resetting the terminal using <code>reset</code>.</p>
119, 2631, 3851, 47913
cmd, git, git-log, invisible
<h1>Why do text/commands become invisible when I use Git log?</h1> <p>I have problems with using Git. Everything works fine when running on CMD and the <code>$</code> shows up and my text shows up. But when I go to my <code>git log</code> my text suddenly disappears. It's just a <code>:</code> and I can type commands b...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,296
cmd
# Why do text/commands become invisible when I use Git log? I have problems with using Git. Everything works fine when running on CMD and the `$` shows up and my text shows up. But when I go to my `git log` my text suddenly disappears. It's just a `:` and I can type commands but not see them. When I go out from the `...
I had this problem after exiting `git log` in Windows Git Bash. I fixed it by resetting the terminal using `reset`.
5898763
How do I get the IP address into a batch-file variable?
62
2011-05-05 13:47:41
<p>I have an odd question, not sure if its possible.</p> <p>I'd like to write a script, and for example I'm going to use ipconfig as my command.</p> <p>Now when you normally run this command theres a ton of output.</p> <p>What I'd like to have is a script that would show only the IP address, for example.</p> <pre><...
314,439
655,947
2026-01-02 09:43:38
5,901,991
51
2011-05-05 17:45:36
653,295
2019-04-24 20:12:25
https://stackoverflow.com/q/5898763
https://stackoverflow.com/a/5901991
<p>This will print the IP addresses in the output of <code>ipconfig</code>:</p> <pre><code>@echo off set ip_address_string="IPv4 Address" rem Uncomment the following line when using older versions of Windows without IPv6 support (by removing "rem") rem set ip_address_string="IP Address" echo Network Connection Test fo...
<p>This will print the IP addresses in the output of <code>ipconfig</code>:</p> <pre><code>@echo off set ip_address_string="IPv4 Address" rem Uncomment the following line when using older versions of Windows without IPv6 support (by removing "rem") rem set ip_address_string="IP Address" echo Network Connection Test fo...
294, 7002
batch-file, ip
<h1>How do I get the IP address into a batch-file variable?</h1> <p>I have an odd question, not sure if its possible.</p> <p>I'd like to write a script, and for example I'm going to use ipconfig as my command.</p> <p>Now when you normally run this command theres a ton of output.</p> <p>What I'd like to have is a scr...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,297
cmd
# How do I get the IP address into a batch-file variable? I have an odd question, not sure if its possible. I'd like to write a script, and for example I'm going to use ipconfig as my command. Now when you normally run this command theres a ton of output. What I'd like to have is a script that would show only the I...
This will print the IP addresses in the output of `ipconfig`: ``` @echo off set ip_address_string="IPv4 Address" rem Uncomment the following line when using older versions of Windows without IPv6 support (by removing "rem") rem set ip_address_string="IP Address" echo Network Connection Test for /f "usebackq tokens=2 d...
24219627
How can I update the system PATH variable permanently from cmd?
46
2014-06-14 11:51:01
<p>We can use <a href="https://ss64.com/nt/setx.html" rel="nofollow noreferrer">setx</a> as discussed <a href="https://stackoverflow.com/a/10411111/248616">here</a>.</p> <pre class="lang-none prettyprint-override"><code>setx PATH &quot;%PATH%;C:\Something\bin&quot; </code></pre> <p>But this command can just make change...
115,193
248,616
2025-06-09 12:26:17
24,219,780
51
2014-06-14 12:10:28
17,034
2022-11-13 19:15:48
https://stackoverflow.com/q/24219627
https://stackoverflow.com/a/24219780
<p>Type <code>setx /?</code> to get basic command help. You'll easily discover:</p> <pre><code>/M Specifies that the variable should be set in the system wide (HKEY_LOCAL_MACHINE) environment. The default is to set the variable un...
<p>Type <code>setx /?</code> to get basic command help. You'll easily discover:</p> <pre><code>/M Specifies that the variable should be set in the system wide (HKEY_LOCAL_MACHINE) environment. The default is to set the variable un...
64, 2631, 6268
cmd, path, windows
<h1>How can I update the system PATH variable permanently from cmd?</h1> <p>We can use <a href="https://ss64.com/nt/setx.html" rel="nofollow noreferrer">setx</a> as discussed <a href="https://stackoverflow.com/a/10411111/248616">here</a>.</p> <pre class="lang-none prettyprint-override"><code>setx PATH &quot;%PATH%;C:\S...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,298
cmd
# How can I update the system PATH variable permanently from cmd? We can use [setx](https://ss64.com/nt/setx.html) as discussed [here](https://stackoverflow.com/a/10411111/248616). ``` setx PATH "%PATH%;C:\Something\bin" ``` But this command can just make changes to the user PATH variable, not the system one. How c...
Type `setx /?` to get basic command help. You'll easily discover: ``` /M Specifies that the variable should be set in the system wide (HKEY_LOCAL_MACHINE) environment. The default is to set the variable under the HKEY_CURRENT_USER...
2111333
How to get last modified date on Windows command line for a set of files?
36
2010-01-21 17:24:08
<p>I have been using the following command to get the file date. However, the <code>fileDate</code> variable has been returning blank value ever since we moved to a different server (Windows Server 2003).</p> <pre><code>FOR /f %%a in ('dir myfile.txt^|find /i " myfile.txt"') DO SET fileDate=%%a </code></pre> <p>Is t...
232,911
4,191
2022-09-10 20:17:14
2,116,420
51
2010-01-22 10:01:37
174,447
2022-02-05 21:55:01
https://stackoverflow.com/q/2111333
https://stackoverflow.com/a/2116420
<p>In the code that follows, change <code>%</code> to <code>%%</code> for use in batch file, for <code>%~ta</code> syntax enter <code>call /?</code></p> <pre><code>for %a in (MyFile.txt) do set FileDate=%~ta </code></pre> <p>Sample output:</p> <pre><code>for %a in (MyFile.txt) do set FileDate=%~ta set FileDate=05/05/20...
<p>In the code that follows, change <code>%</code> to <code>%%</code> for use in batch file, for <code>%~ta</code> syntax enter <code>call /?</code></p> <pre><code>for %a in (MyFile.txt) do set FileDate=%~ta </code></pre> <p>Sample output:</p> <pre><code>for %a in (MyFile.txt) do set FileDate=%~ta set FileDate=05/05/20...
64, 1796, 7002
batch-file, command, windows
<h1>How to get last modified date on Windows command line for a set of files?</h1> <p>I have been using the following command to get the file date. However, the <code>fileDate</code> variable has been returning blank value ever since we moved to a different server (Windows Server 2003).</p> <pre><code>FOR /f %%a in ('...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,299
cmd
# How to get last modified date on Windows command line for a set of files? I have been using the following command to get the file date. However, the `fileDate` variable has been returning blank value ever since we moved to a different server (Windows Server 2003). ``` FOR /f %%a in ('dir myfile.txt^|find /i " myfil...
In the code that follows, change `%` to `%%` for use in batch file, for `%~ta` syntax enter `call /?` ``` for %a in (MyFile.txt) do set FileDate=%~ta ``` Sample output: ``` for %a in (MyFile.txt) do set FileDate=%~ta set FileDate=05/05/2020 09:47 AM for %a in (file_not_exist_file.txt) do set FileDate=%~ta set FileD...
15466298
Simple caret (^) at end of Windows batch file consumes all memory
62
2013-03-17 21:12:37
<p>This simple batch file in relatively short order consumes all available memory on Windows 7 (x64). What's going on? and what precautions can be taken to ward against it?</p> <pre><code>any-invalid-command-you-like-here ^ </code></pre> <p>Apparently necessary preconditions to exhibit the effect: </p> <ul> <li>the ...
16,507
14,420
2019-11-18 16:30:45
15,469,225
50
2013-03-18 03:15:07
891,976
2019-11-18 16:30:45
https://stackoverflow.com/q/15466298
https://stackoverflow.com/a/15469225
<h3>Thoughts</h3> <p>The cause of this (from my understanding) is due to the cmd interpreter looking for a character to escape since the <code>^</code> is the batch escape character. Instead of properly identifying the end of file <code>eof</code> in this scenario, cmd just keeps looping and initializing something whi...
<h3>Thoughts</h3> <p>The cause of this (from my understanding) is due to the cmd interpreter looking for a character to escape since the <code>^</code> is the batch escape character. Instead of properly identifying the end of file <code>eof</code> in this scenario, cmd just keeps looping and initializing something whi...
64, 136, 2631, 7002
batch-file, cmd, security, windows
<h1>Simple caret (^) at end of Windows batch file consumes all memory</h1> <p>This simple batch file in relatively short order consumes all available memory on Windows 7 (x64). What's going on? and what precautions can be taken to ward against it?</p> <pre><code>any-invalid-command-you-like-here ^ </code></pre> <p>Ap...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,300
cmd
# Simple caret (^) at end of Windows batch file consumes all memory This simple batch file in relatively short order consumes all available memory on Windows 7 (x64). What's going on? and what precautions can be taken to ward against it? ``` any-invalid-command-you-like-here ^ ``` Apparently necessary preconditions ...
### Thoughts The cause of this (from my understanding) is due to the cmd interpreter looking for a character to escape since the `^` is the batch escape character. Instead of properly identifying the end of file `eof` in this scenario, cmd just keeps looping and initializing something while looking for the character t...
32554448
Command line arguments to Docker CMD
46
2015-09-13 20:54:42
<p>I want to pass in a parameter into a docker CMD. For example, if the contents of <code>Dockerfile</code> are</p> <pre><code>FROM ubuntu:15.04 CMD ["/bin/bash", "-c", "cat", "$1"] </code></pre> <p>Then I want to run as follows:</p> <pre><code>docker build -t cat_a_file . docker run -v `pwd`:/data cat_a_file /data/...
83,243
904,050
2024-04-17 17:22:30
32,554,607
50
2015-09-13 21:13:49
4,332
2015-09-13 21:13:49
https://stackoverflow.com/q/32554448
https://stackoverflow.com/a/32554607
<p>Use <code>ENTRYPOINT</code> for stuff like this. Any <code>CMD</code> parameters are appended to the given <code>ENTRYPOINT</code>.</p> <p>So, if you update the Dockerfile to:</p> <pre><code>FROM ubuntu:15.04 ENTRYPOINT ["/bin/bash", "-c", "cat"] </code></pre> <p>Things should work as you wish.</p> <p>Also, as y...
<p>Use <code>ENTRYPOINT</code> for stuff like this. Any <code>CMD</code> parameters are appended to the given <code>ENTRYPOINT</code>.</p> <p>So, if you update the Dockerfile to:</p> <pre><code>FROM ubuntu:15.04 ENTRYPOINT ["/bin/bash", "-c", "cat"] </code></pre> <p>Things should work as you wish.</p> <p>Also, as y...
90304, 108477, 164539
docker, docker-cmd, dockerfile
<h1>Command line arguments to Docker CMD</h1> <p>I want to pass in a parameter into a docker CMD. For example, if the contents of <code>Dockerfile</code> are</p> <pre><code>FROM ubuntu:15.04 CMD ["/bin/bash", "-c", "cat", "$1"] </code></pre> <p>Then I want to run as follows:</p> <pre><code>docker build -t cat_a_file...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,301
cmd
# Command line arguments to Docker CMD I want to pass in a parameter into a docker CMD. For example, if the contents of `Dockerfile` are ``` FROM ubuntu:15.04 CMD ["/bin/bash", "-c", "cat", "$1"] ``` Then I want to run as follows: ``` docker build -t cat_a_file . docker run -v `pwd`:/data cat_a_file /data/Dockerfil...
Use `ENTRYPOINT` for stuff like this. Any `CMD` parameters are appended to the given `ENTRYPOINT`. So, if you update the Dockerfile to: ``` FROM ubuntu:15.04 ENTRYPOINT ["/bin/bash", "-c", "cat"] ``` Things should work as you wish. Also, as you don't need the `$1`, you should be able to change it to: ``` FROM ubun...
8447185
To prevent a function from printing in the batch console
40
2011-12-09 14:47:54
<p>Well, the headline seems to me sufficient. I use some function that at some points print something in the console. As I can't modify them, I would like to know if there is a solution to not printing while using these functions.</p>
35,384
1,069,655
2023-09-04 19:48:54
8,447,352
50
2011-12-09 14:59:18
746,961
2020-09-30 12:16:37
https://stackoverflow.com/q/8447185
https://stackoverflow.com/a/8447352
<p>Yes, you can redirect <code>sys.stdout</code>:</p> <pre><code>import sys import os old_stdout = sys.stdout # backup current stdout sys.stdout = open(os.devnull, &quot;w&quot;) my_nasty_function() sys.stdout = old_stdout # reset old stdout </code></pre> <p>Just replace <code>my_nasty_function</code> with your actu...
<p>Yes, you can redirect <code>sys.stdout</code>:</p> <pre><code>import sys import os old_stdout = sys.stdout # backup current stdout sys.stdout = open(os.devnull, &quot;w&quot;) my_nasty_function() sys.stdout = old_stdout # reset old stdout </code></pre> <p>Just replace <code>my_nasty_function</code> with your actu...
16, 87, 7002
batch-file, printing, python
<h1>To prevent a function from printing in the batch console</h1> <p>Well, the headline seems to me sufficient. I use some function that at some points print something in the console. As I can't modify them, I would like to know if there is a solution to not printing while using these functions.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%cmd%' OR '%batch%'; a.Body contains code block; q.Score > 5; a.Score > 10
12,302
cmd
# To prevent a function from printing in the batch console Well, the headline seems to me sufficient. I use some function that at some points print something in the console. As I can't modify them, I would like to know if there is a solution to not printing while using these functions.
Yes, you can redirect `sys.stdout`: ``` import sys import os old_stdout = sys.stdout # backup current stdout sys.stdout = open(os.devnull, "w") my_nasty_function() sys.stdout = old_stdout # reset old stdout ``` Just replace `my_nasty_function` with your actual function. **EDIT:** Now should work on windows aswell...