Skip to main content

All Questions

Tagged with
1 vote
1 answer
1k views

Escaping Parenthesis within a file path Parameter in a batch script

I've created a batch script to do some basic file management for me. It's passed in either a directory or file path, along with a category. The program will then Copy the file to another directory of ...
freebird's user avatar
  • 162
1 vote
1 answer
481 views

Prevent deleted files from running in the Startup folder

I have a batch script in my startup folder called everytime.bat that deletes all files except for the batch script. @echo off REM delete everything in startup except this file cd "C:\ProgramData\...
Kat's user avatar
  • 135
3 votes
3 answers
218 views

Delete files depending on positions/file name in the current folder / define multiple values effectively

How do I effectively delete several files depending on their positions(edit: or retrieve the files by their number) in the current folder? Preferably I need a solution with a normal .bat file. The ...
atereou's user avatar
  • 359
1 vote
1 answer
1k views

How to recursive copy files from a list of files in a text file using a Windows batch file?

Parent folder: Root Subfolder1: Has 12000 files i.e. subfolder1\885.txt Subfolder2: Has 15000 files i.e. subfolder2\882.txt Source file list names.ext contains 500 different names: 882.txt 550.txt ...
Asad Ali Hussaini's user avatar
2 votes
1 answer
4k views

Pass variable to filename in Windows FOR / DO Batch File

I have the following code where I systematically go through and compress each file individually. I don't care what the file name is, but I want it hidden more or less so will just call each file "file ...
HTWingNut's user avatar
  • 509
2 votes
1 answer
3k views

Batch File for Extracting File Path and File Name from Log file

I am really trying to figure this out, so bear with me, and thanks in advance for any assistance. I'm still struggling with understanding proper use of FOR /F "Delims" and "Tokens". EDIT: Ultimately ...
HTWingNut's user avatar
  • 509
0 votes
2 answers
196 views

%1 in batch file not regestering in windows 10

I am trying to create a batch file for an installer of a file type. The problem is that whenever I run the batch file the %1 disappears and is not applied to ftype. Instead, it is left with just the ...
AKA_Beest's user avatar
0 votes
0 answers
164 views

How do I wait to execute a command which starts a service that is dependent an another service's start?

I need to write a batch script to run two services in Windows, let's call them S1 and S2. The start of S2 depends on the start of S1. I want to run S2 only after S1 starts listening on a particular ...
sv2311's user avatar
  • 9
0 votes
2 answers
12k views

How to create multiple txt files with incrementing numbers and writing in them using batch files (.bat)

I want to create multiple txt files with incrementing numbers with batch; here's my example @echo off for /l %i in (1,1,13) do @echo bla bla bla > "%i.txt" @echo bla bla blo > "%i.txt" ...
Rachid's user avatar
  • 71
1 vote
1 answer
62 views

Batch expert needed file cannot be for looped because of first symbol

I'm having a bit of an issue in the link there is a text file and you will notice that first character is unknown symbol and after batch tries to for loop it only copies that first character and stops ...
pamomil605's user avatar
0 votes
0 answers
1k views

Opening files with long path in Windows using CMD bat

We sometimes need to allow users in our company to open files with long paths on Windows. One of the solutions I found (https://support.centrestack.com/hc/en-us/articles/360026297293-How-to-Open-Files-...
MyUserName's user avatar
1 vote
0 answers
710 views

I need to run a batch file from USB which will run a second batch file on C:, then allow me to remove the USB media. How can I do this?

I currently have a script that copies a directory on USB to C:, then runs the following line to switch to a local batch file: call "cmd /c start c:\update\patcher.cmd" Once the script on C:\ starts ...
Jake Nixon's user avatar
1 vote
2 answers
544 views

.bat script output comparison

I am trying to adjust power/seep settings on windows 10 using a .bat file. I found that you can easily import a power scheme using the powercfg -import however the issues is trying to set the power ...
Tyler Coleman's user avatar
0 votes
3 answers
6k views

Convert bat to exe programmatically [closed]

How can I convert .bat file to .exe programmatically? Please, not via iexpress. I need the exe file to execute the script itself, and not delegate cmd
Tix's user avatar
  • 111
0 votes
2 answers
2k views

Bat script to .exe with relative paths

I know how to convert bat to exe from here, but I have a problem that there are relative paths in the script itself, and there is no way to make them absolute, and the script inside exe is launched in ...
Tix's user avatar
  • 111
1 vote
3 answers
3k views

batch script for renaming a daily backup file

Everyday I have a program that creates a backup file. There is no way to set the program to keep multiple backups, it simply overwrites or removes the previous backup but I don't like that behavior. ...
MikjoA's user avatar
  • 11
1 vote
1 answer
602 views

Batch files: Interact with a shell instance opened by a batch script in an other instance

My goal is to have a python script calling a batch script calling a cmd file to load environment variables and executing some commands with those. The first line of my batch script is to call a cmd ...
jmlesfrite's user avatar
0 votes
0 answers
188 views

How to make a batch file that copies itself to all available network locations?

I am trying to make a batch which can copy itself to all available network locations. I know how to make a batch file that can copy itself to a network location whose name is known. I want to make a ...
Arin Kumar's user avatar
1 vote
1 answer
4k views

Command Line Windows: How can I set a global variable within a call?

I want to change a counter variable within a call function. In my example I want to count all subfolders (= count_all) and afterwards I want to increment the count of the subfolders it successfully ...
tar's user avatar
  • 78
0 votes
2 answers
2k views

How to filter full file name or full folder name only from input path using batch?

I am running the following command, set /p "filepath=Drag and drop your file >" cls for %%a in ("%filepath%") do echo %%~nxa pause >nul It works good when the file name is single word. But, ...
Philip's user avatar
  • 696
2 votes
2 answers
627 views

How to avoid showing file name in batch output file?

I am running command, Find /C /I "pass" "log.txt" > output.txt output am getting, ---------- LOG.TXT: 2 Getting this output because, there is two time the word "pass" comes in log.txt file. ...
Philip's user avatar
  • 696
0 votes
4 answers
525 views

Randomly execute 35 Batch files

I have 35 batch files in same folder. All batch files have different names and codes inside, i want to create batch file from where i can run 35 batch files randomly with out knowing their names or ...
shikhahiya's user avatar
1 vote
0 answers
195 views

How do I copy a file chosen from a file dialog, then rename the copied file, all in one batch script?

I'm trying to semi-automate the setup of my Nintendo e-Reader .sav files (however, the file doesn't have to have a .sav file extension) using a batch script. The non-automated way I'd use would be to ...
Niall Ward's user avatar
0 votes
2 answers
2k views

How to open text file from two or more words named folder using batch?

I have 2 files. open.bat & file.txt I am trying to open file.txt from open.bat The problem is, file.txt is located in d:\Tom and Jerry\file.txt this path, which name a folder named with three ...
Philip's user avatar
  • 696
4 votes
3 answers
908 views

How to find OS Architecture using batch with only numberic output?

I am running following command, @echo off cls wmic os get osarchitecture > win.txt for /f "skip=1" %%G IN (win.txt) do echo %%G pause>nul Actual output am getting is, Echo is off Expected ...
Philip's user avatar
  • 696
3 votes
1 answer
4k views

How to extract only file name from the path?

I am running the code, set /p "filepath=Drag and drop your file >" cls echo Your file name is : %filepath% pause>nul output i am getting Your file name is : c:/users/philip/desktop/file.txt ...
Philip's user avatar
  • 696
1 vote
3 answers
3k views

Recursivly merge txt files in a batch

I have one folder that contains several subfolders and each of those contains 10k+ small txt files. Now I need to merge all files from each subfolder into one big txt file for further processing. If ...
suckerp's user avatar
  • 111
-4 votes
2 answers
5k views

how to create a batch script that creates a text file and takes all the names of files in another folder and stores them in the original text file

The instructions are as follows : The script must create a file named files.txt and display its contents. The file must contain all the names (only) in the %windir%\system32 directory that meet the ...
TruthSeeker's user avatar
1 vote
1 answer
342 views

Batch file to open multiple tabs in different time in firefox already opened

I use portable firefox 60esr. until yesterday I could with a batch file to open in the same firefox open several tabs with a delay, but from today if I reopen firefox with batch file I appear a ...
pachiro's user avatar
  • 53
-1 votes
2 answers
3k views

Batch Script: Move files into corresponding folders with similar name

I am trying to set up a paperless practice and store all patient data electronically. I have already created 8000 folders (1 - 8000) and I now need to move approximately 16000 .pdf files into ...
KGov's user avatar
  • 1
0 votes
2 answers
1k views

batch file ren command Self destruct

sorry for the noob question, but i'm a beginner. I have a .bat that turns all of the folders containment's to a .jpeg using a wiled card because the containment's are empty extensions @echo off ren ...
Divided By 0's user avatar
1 vote
1 answer
910 views

Batch: Unexpected Variable Results in Subroutine

An answer to a previous question suggests this FOR line. Now I am trying to use the variable. My batch script at present: @echo off cls for %%G in ("3D Objects","Documents","Downloads","Music","...
Ray Woodcock's user avatar
2 votes
1 answer
978 views

Batch File Not Looping for Non-File Items in a List

Within an elevated command using Windows 10, I run this batch file: @echo off cls for /f "tokens=1-6 delims=," %%G in ("3D Objects,Documents,Downloads,Music,Pictures,Videos") do ( echo %%G ) I ...
Ray Woodcock's user avatar
1 vote
1 answer
648 views

Batch to rename unknown folder name to particular name

I have a folder named Results inside that results folder a sub folder called Result***** "*" = some random numbers i donno what will be those random number its keep changing and random.. i want to ...
Philip's user avatar
  • 696
0 votes
1 answer
3k views

Batch to convert txt file into json file

I have a text file named, proxy.txt which contains, 84.15.160.174:4145 178.208.17.195:9999 58.253.154.117:9999 112.87.71.194:9999 I found this URL » https://shancarter.github.io/mr-data-converter/ ...
Philip's user avatar
  • 696
0 votes
1 answer
267 views

Batch to filter the text or number between symbols from a text file

I have a text file, file.txt which contains, [{"84.15.160.174:4145":"178.208.17.195:9999"}, {"84.15.160.174:4145":"58.253.154.117:9999"}, {"84.15.160.174:4145":"112.87.71.194:9999"}, {"84.15.160.174:...
Philip's user avatar
  • 696
1 vote
0 answers
668 views

Task Scheduler does not run bat file at the bat file's location

I am running a server and I'm intending to run a .bat file on startup. However, when it runs, it cannot read the files from its original location. Heres a better explanation: The .bat file runs "...
YJJcoolcool's user avatar
0 votes
1 answer
4k views

whitespace padding a file length using echo in a windows batch file

I'm using a for loop in a windows .bat file to make a text-file listing files in directories. FOR /R %%G in (*) DO ( ECHO %%~zG %%~nxG >> zzz-list.txt ) [Phone won't let me input a tab ...
user3082's user avatar
  • 143
1 vote
2 answers
2k views

Can we skip a argument in the (%*)?

How can I skip an argument like %~1 in the %*? @echo off title cls :loop set /p command= call :command %command% goto :loop :command if "%~1"=="title"( %~1 %* ) goto :eof I'm ...
Hüseyin Teoman Deniz's user avatar
0 votes
0 answers
1k views

Batch File - Copying over directories with spaces

The Goal I want to: 1 - Loop over directories on a remote network and create a directory (if it doesn't exist) locally 2 - Within the sub-directory on the remote file, copy the files to the ...
StephanieQ's user avatar
0 votes
1 answer
2k views

Windows CMD - can't call .cmd file from .bat file

I created A.bat file inside that file i am trying to call B.cmd file call B.cmd When trying to invoke the below command in CMD Terminal call A.bat Output is 'B.cmd' is not recognized as an ...
Net Sim's user avatar
  • 101
1 vote
1 answer
561 views

REG ADD REG_SZ where Value contains embedded double quotes (redux)

This is driving me bananas but it must be something very simple. I am trying to modify an ImagePath Value (REG_SZ) for a Service in a Batch script using REG ADD, where the Value Data contains ...
Neil Weicher's user avatar
0 votes
1 answer
3k views

REG ADD REG_SZ where Value contains embedded double quotes

This is driving me bananas but it must be something very simple. I am trying to add an ImagePath Value (REG_SZ) in a Batch script using REG ADD, where the Value Data contains embedded "double quotes"....
Neil Weicher's user avatar
0 votes
1 answer
228 views

Set a limit on the amount of text entered into Set /P [closed]

I use set /p newname= here: I need to set a limit on set /P to prevent this issue. When the character limit is reached, it needs to prevent entering more text.
Hüseyin Teoman Deniz's user avatar
0 votes
1 answer
3k views

Pass paths of directory contents as arguments to batch file

I have a batch file ("drag_target.bat") onto which I drag multiple files. Windows then passes the dragged file paths as arguments: drag_target.bat "dragged file 1 path" "dragged file 2 path" ... A ...
Museful's user avatar
  • 213
0 votes
1 answer
225 views

How Can I Use Different Programing Languages in a Batch File?

i saw a BAT file there have different programing language used in there it is (Java Script) @if (true == false) @end /* @echo off bg font 6 & cls cmdwiz showcursor 0 if defined __ goto :START ...
Hüseyin Teoman Deniz's user avatar
0 votes
1 answer
1k views

When a batch-program will go to next line?

I have a batch file for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,...
user1049805's user avatar
3 votes
2 answers
1k views

How to zip a folder and turn it into an executable which points to a .bat file inside it?

I have a folder with a batch file in it. I don't want users to search for that batch file and then run it. Instead copy it as a portable software and just click the folder(actually an executable) ...
Tarun Maganti's user avatar
0 votes
1 answer
3k views

How to create a batch file to retrieve a password from a password generator?

I want to create a batch file to retrieve a password from an EXE on the computer. It is a password that changes everyday. I don't get any results with the code below. set /p input="C:\Program Files\...
drive's user avatar
  • 21
0 votes
1 answer
810 views

Compare files using robocopy in for loop

Problem I want to solve: Compare files in one directory to files in a subdirectory. If they match, delete the file in the top directory. This is for Windows and I would like to use Windows Batch ...
Registered User's user avatar

15 30 50 per page
1 2
3
4 5
8