Search found 4150 matches

by Squashman
28 Jul 2021 07:40
Forum: DOS Batch Forum
Topic: Batch script execution controller
Replies: 1
Views: 99

Re: Batch script execution controller

I am not sure why you are checking if the process is still running. You are not doing anything with that information other than just checking it is running and if it is no longer running then restart the process again. Why couldn't your script be as simple as this? set /A i=0 :infinite_loop set /A i...
by Squashman
22 Jul 2021 08:43
Forum: DOS Batch Forum
Topic: Parenthetical Redirection
Replies: 7
Views: 240

Re: Parenthetical Redirection

You already had the answer in aGerman's post

Code: Select all

@echo off
for /f "tokens=*" %%i in ('powercfg /GetActiveScheme') do for /f "tokens=*" %%j in ("%%i") do set "pwrPlan=%%j"

(
setlocal enabledelayedexpansion
echo Powerplan:
echo !pwrPlan!
echo(
endlocal
)
by Squashman
21 Jul 2021 13:13
Forum: DOS Batch Forum
Topic: Parenthetical Redirection
Replies: 7
Views: 240

Re: Parenthetical Redirection

Use this as a best practice.

Code: Select all

set "logonTypeInfo=Cached Interactive (Locally stored network credentials^)"
by Squashman
20 Jul 2021 09:53
Forum: DOS Batch Forum
Topic: Batch random number through C executable
Replies: 4
Views: 282

Re: Batch random number through C executable

findstr wrote:
20 Jul 2021 01:49
Can you, please, show me a C code which will generate random numbers?
Many thanks!
Well last I checked this wasn't a C programming forum.
Simple enough to call out to Powershell from a batch file and assign it to a variable.

Code: Select all

FOR /F "delims=" %%G IN ('powershell "GET-RANDOM"') do set _rand=%%G
by Squashman
07 Jul 2021 19:02
Forum: DOS Batch Forum
Topic: Robocopy syntax
Replies: 1
Views: 282

Re: Robocopy syntax

Nope. The Syntax is pretty clear from the help file. Usage :: ROBOCOPY source destination [file [file]...] [options] source :: Source Directory (drive:\path or \\server\share\path). destination :: Destination Dir (drive:\path or \\server\share\path). file :: File(s) to copy (names/wildcards: default...
by Squashman
15 Jun 2021 22:36
Forum: DOS Batch Forum
Topic: Batch script to rename text files to match image files names.
Replies: 5
Views: 553

Re: Batch script to rename text files to match image files names.

Type would be slower. You just need to use the command modifiers to get the base file name and then add the txt extension.

copy "Placehold.txt" "%%~na.txt"
by Squashman
15 Jun 2021 22:32
Forum: DOS Batch Forum
Topic: A Batch File to Process Multiple FFmpeg Commands
Replies: 1
Views: 461

Re: A Batch File to Process Multiple FFmpeg Commands

Your code as posted will run only one at a time in a batch file.
by Squashman
24 May 2021 08:42
Forum: DOS Batch Forum
Topic: If not exist command
Replies: 1
Views: 626

Re: If not exist command

You have not shown us enough code to make any definitive solution to your problem.

Not understanding why you are checking it after the robocopy command.
by Squashman
23 May 2021 22:07
Forum: DOS Batch Forum
Topic: Sending command to a single in a text file
Replies: 2
Views: 651

Re: Sending command to a single in a text file

Why not....?

Code: Select all

echo %computername% %date%
by Squashman
17 May 2021 07:41
Forum: DOS Batch Forum
Topic: How to add files larger than 100 kb to the 7z archive?
Replies: 1
Views: 694

Re: How to add files larger than 100 kb to the 7z archive?

The FOR command provides a mechanism to get the size of a file.

Code: Select all

for %%G IN (somefile.txt) do @echo %%~zG
You may have remembered this when you were directed to read the help file when you asked this question
by Squashman
15 May 2021 21:12
Forum: DOS Batch Forum
Topic: Run program with different methods in loops
Replies: 3
Views: 855

Re: Run program with different methods in loops

liargof wrote:
15 May 2021 06:14
Thank you!

If I want to see each method running in separate CMD window, should I remove the "/b" that comes after the "start"?

What I want is that each method will run in loops in its own command window
What is stopping you from testing that code change?
by Squashman
10 May 2021 12:39
Forum: DOS Batch Forum
Topic: Batch Rename of files in a folder
Replies: 1
Views: 728

Re: Batch Rename of files in a folder

You were pretty much given the code in your previous question from 6 years ago.

Code: Select all

FOR /F "tokens=1-6 delims=-" %%A IN ('dir /a-d /b *.dwg') DO rename "%%A-%%B-%%C-%%D-%%E-%%F"  "%%A-%%B-%%C-%%D-1961-%%F"
by Squashman
06 May 2021 07:55
Forum: DOS Batch Forum
Topic: A tool for managing multiple running dos batches
Replies: 8
Views: 1196

Re: A tool for managing multiple running dos batches

Hi Squash, Thanks, but I think the users need an interface. But you're right, TASKLIST can be useful in some contexts, when writing batches that need to check if other batches are running. TASKLIST with verbose output will also show you what you want. Then you can use TASKKILL. Not that hard to bui...
by Squashman
06 May 2021 07:55
Forum: DOS Batch Forum
Topic: A tool for managing multiple running dos batches
Replies: 8
Views: 1196

Re: A tool for managing multiple running dos batches

what does this TASKKILL command do? H:\>taskkill /? TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F] Description: This tool is used to terminate tasks by process id (PID) or image name. Parameter List: /S system Specifies the remote syst...