New answers tagged

0 votes

Using Findstr to search for drive letter

You're trying to list all the disks, but mountvol does not do that. The command you want is wmic with one of the following : wmic logicaldisk get name wmic logicaldisk get caption
  • 424k
0 votes

Determine if command is recognized in a batch file

set JAVA_CMD= for /f %i in ('where java 2^>nul') do ( if exist "%i" set "JAVA_CMD=%i" ) echo %JAVA_CMD% try this.
  • 101
0 votes

how to add extension one or more while using xcopy

@echo off setlocal enabledelayedexpansion for %%A in (*.bat) do ( for /f "delims=" %%B in ("%%A") do set fname=%%~nB for /f "delims=" %%C in ("%%A") ...
1 vote

Batch Rename - Parent folder + text + Incrementing Number per directory

Please se if this is like expected: You have to drag and drop the parent folder to the batch file... @echo off if exist "%~1" (if not exist "%~1\" exit) else (exit) set Parent=%~...
0 votes
Accepted

Batch file - Delete all files in subdirectories which do not contain text in filename

In your command line for /f "delims=" %i in ('2^>nul dir /a:a /b /s ^| findstr /vi export')do del /q /a "%~fi" In your batch file @echo off cd /d "D:\Full\Path\To\Your\...
  • 6,720
0 votes

How to query a different registry path with wmic?

You would have to search inside each folder you mentioned HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\...
3 votes
Accepted

merge 3 txt files with custom format

Yes, it is possible to merge the three files into the format you described. You can use a simple script to do this. Here is an example of how you could do it in Python: # Open the first file in read ...
  • 46
1 vote

Prevent any batch file from closing automatically

You can install a program from Sysinternals Suite called Autoruns. It will list everything that is being started during logon so you can inspect the scripts and delete what you find malicious. Trying ...
  • 832
0 votes

Switch to visual studio prompt and execute command from inside batch file

You need to run the vcvars32.bat or vcvars64.bat instead. As of this writing these were in C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build. Answering this as I ran into the ...
0 votes

I want to rename files containing spaces, hyphens etc

you can assign 1 value to a variable. so I would create another variable with the name pattern2 for example and pass another rename command in the end using pattern2. like this @echo off Setlocal ...
  • 86
0 votes

Setting compatibility flags on executables residing on removable media from a batch file

I think all you need is the following command: wmic logicaldisk get DeviceID, Description It will check all logical disks and show you the device id plus whether it is a local or removable drive. And ...
  • 86
0 votes

batch script - was unexpected at this time

batch script - was unexpected at this time In a batch file you need to use %%a not %a. FOR command variables which use a single leading % on the command line or a double leading %% when used in a ...
  • 147k
1 vote

Changing output file name in a batch file

Is there an easy way remove the last 4 characters of %~n1? You need to use the substring operator. Try the following cmd script: @echo off rem avoid polluting global environment space setlocal set &...
  • 147k
0 votes

How would I diff two mbox files in an intelligent way?

Some 5 years later. I had to compare 306MB and 338MB Thunderbird backed-up mailboxes. So I put all the excellent advice into a self-contained helper script that makes the difference mbox2 - mbox1. In ...
1 vote
Accepted

Redirecting the output to a file and command prompt simultaneously

As per my comment, you are mixing syntax improperly. %~dp0 ...is not any PowerShell will understand. The PowerShell equivalent of that is... $PSScriptRoot Also, You are trying to run batch/cmd ...
  • 4,280
0 votes
Accepted

Create folder with PC Serial Number and redirect log text file in it using batch script

Script is executing without any error but unable to fulfil my requirement Observations: You have a space in set "myDIR= %SerialNumber%" It should be set "myDIR=%SerialNumber%" ...
  • 147k
0 votes

How do you rotate an entire directory of videos with ffmpeg?

One Line Solution npx rotate-video --source=source_path --destination=destination_path --extension=MP4 --angel=270 Note: You need to install FFMPEG CLI first install
2 votes
Accepted

Capture batch output and save it in TXT File as log

UPDATED RESPONSE The batch file becomes: PowerShell.exe -ExecutionPolicy Bypass -File %~dp0Check.ps1 pause And, using Tee-Output which takes the output of the previous command in the pipeline and ...
0 votes

youtube-dl changing the format output of %(upload_date)s

There is no way to change it in youtube-dl, but you can use its more advanced fork yt-dlp and use the following output format: %(upload_date>%Y-%m-%d)s Working example: youtube-dl -f 'bestvideo[...
0 votes
Accepted

PowerShell command in a batch script

With Powershell, you can iterate through a list of files and execute a command afterwards. For example: # get all textfiles in a variable. $files = get-childitem *.txt # Loop collection and perform ...
  • 57.3k
0 votes
Accepted

Batch create folders based on extension and move files into them

If I got you right it would be something like this. Go through the subfolders of source, inside the subfolder if there are pdf files create a folder called Representation_1 and move all pdf files to ...
0 votes

Is there a way to kill explorer.exe and then run a batch file that starts it again?

You can make a batch file, The restart.bat would look this: taskkill /F /IM explorer.exe & start explorer
0 votes

Filter informations in regedit (Batch)

You can filter with regex in VBScript and execute it from a batch file like this example : @echo off & Mode 70,3 & color 0B Title Extarcting EXE Paths from Registry Key set Key_Store="...
  • 1,286
0 votes

Connect automatically to wifi as soon as available and if it gets disconnected connect again

You could use the Task Scheduler to schedule periodically the reconnection every few minutes by using the command: netsh wlan connect name=WIFI_SSID You could base a batch script to schedule on this ...
  • 424k
0 votes

How do I force Windows Command Processor to launch in the background?

To be honest.. I know very little about stata.. but I do know how to RTFM and hack crap to make it do what I want (usually). I don't have stata but I can tell you your options and how to get around ...
1 vote
Accepted

How can I make txt files with some script with Batch files?

If your question is about creating a multi-line text-file in batch with special characters, you may uses the append operator >> and the escape operator ^, like this : echo ^<...
  • 424k
0 votes

BATCH : The terminator ' is missing in the string

I found a solution while trying to put the name of the counter in a variable. My problem was the '%' in the my command because the batch file was certainly searching for a variable name. So I just ...
-1 votes

How do I get 64 bit %ProgramFiles% in batch file that is run from 32 bit application?

In a batch file is spawned by a 32bit exectutable, I found that all ProgramFiles related environment variables contain the "Program Files (x86)" location. As a kludge, you can assume the ...
  • 139
1 vote
Accepted

Open .mp4 files in Adobe Media Encoder through a batch file

AME does not support any command line arguments directly that isn't passing the application a script. The best way to do this is to open the app, create a "watch folder" and configure the ...
  • 3,251
0 votes
Accepted

Issue with reg add command for automating desktop icon selections

@echo off && setlocal enabledelayedexpansion Title <nul & cd /d "%~dp0" & OpenFiles 1>nul 2>&1 Title Lets making Imaging Policies a bit faster!! set _bar=<...
  • 6,720

Top 50 recent answers are included