batch-file

Batch/VBS: asking for user input and with his data replace a string in a existent text file

梦想与她 提交于 2020-01-06 08:21:17
问题 I need a vbs or batch to ask to user a value and after, put this value in a text file where I've to replace an existent value... Currently, with a batch file, I can get user input and put it into a variable, but I can't find any feature to find a "part of a numeric string" (ip address) in to text file and replace it. ES: Let's say that the text file is "hosts.txt": 172.16. 16.1 serverA 172.16. are constant value, I've to replace only the other 2 octet " 16.1 "... All tools that I know can't

batch search and replace folders names

断了今生、忘了曾经 提交于 2020-01-06 08:17:08
问题 i'm using batch file (named as folder.bat) to add the string "_v0_1" for each foler name under "my folder" (i have about 100 folders under "my folder") I'm calling my batch (folder.bat) from a onother batch file that contains this rows(for example): call folder arbiter_logic call folder arbiter_logic_old the problem, is that the batch rename folders also when the folder name is longer than the variable name (%1) and i want to avoid it . I want that the renaming action will execute only if

How to set variable with the result of findstr

本小妞迷上赌 提交于 2020-01-06 08:16:14
问题 I am trying to write a batch file which searches for pdf files and finds how many pages they have and loop all pages. I wrote the following. I can find the files, I can even find the pagecounts with a tool named pdftk. The results is as below. C:\Users\test\Documents\fishes\Fish_1.pdf NumberOfPages: 5 How can I set a variable which has the value of 5 ? @ECHO off for /R %%i IN (*.pdf) DO ( ECHO %%i "C:\Program Files (x86)\PDF Labs\PDFtk Server\bin\pdftk.exe" %%i dump_data | findstr

Variable in variable batch

倖福魔咒の 提交于 2020-01-06 08:16:11
问题 Alright, I need help here. I have done this before where you have variable1 (let's say it's eat1=apple), variable2 (this is eat2=orange), and variable3 (appaleorange=apple and orange). I need it to do this: echo Apple:%eat1% echo Orange:%eat2% echo Apple & Orange:%eat1%%eat2% Now, you can see my problem. That above script wouldn't show the word and, only appleorange. That isn't my script and the reason I need this is because I have multiple variables with numbers in them. I have done this

Optimizing or speeding up reading from .xy files into excel

瘦欲@ 提交于 2020-01-06 08:15:47
问题 I have a few .xy files (2 columns with x and y values). I have been trying to read all of them and paste the "y" values into a single excel file (The "x" values are the same in all these files). The code I have till now reads the files one by one but its extremely slow (it takes about 20 seconds on each file). I have quite a few .xy files and the time adds up considerably. The code I have till now is: import os,fnmatch,linecache,csv from openpyxl import Workbook wb = Workbook() ws = wb

Pass batch variables with spaces in them to powershell script?

末鹿安然 提交于 2020-01-06 08:13:27
问题 I have a batch/powershell script that I use to make a list of all my movies and tv series but have run into a small problem, I can't have spaces in my batch variables when passing them to the powershell script. I have tried all kinds of combos of ' and " around the variables without any luck. My batch variables SETLOCAL enabledelayedexpansion SET "listfolder=%CD%\ContentList\" SET "listname1=TVSeries" SET "RootFolder1=\\SERVER\Storage\TV Series\" SET "Folder1Width=70" SET ScanFolder1=TRUE My

How do I use the FOR batch command to find all text between two specific symbols?

自古美人都是妖i 提交于 2020-01-06 07:44:07
问题 I have a batch script I made to extract chat lines from a log on my gaming server. The input file has text lines like this: 12/30/2015 12:42:03 : #[PLAYERNAME] Hello! I then process each line of the log to extract the player name as follows: for /f "tokens=2 delims=[]" %%d in ("!LINE!") do (set "NAME=%%d") This works fine IF the player has no [] bracket characters in their name. If their name looks like the following: 12/30/2015 12:42:03 : #[<][PLAYERNAME][>] Hello! Or anything similar, then

search and replace file names - bug fix

天大地大妈咪最大 提交于 2020-01-06 07:35:51
问题 I have a script that changes particular string within files names (the file stores in "my_folder"): Set objFso = CreateObject("Scripting.FileSystemObject") Set Folder = objFSO.GetFolder("g:\my folder") For Each File In Folder.Files sNewFile = File.Name sNewFile = Replace(sNewFile,"._epf","_v0_1._epf") if (sNewFile<>File.Name) then File.Move(File.ParentFolder+"\"+sNewFile) end if Next the scrpit works fine if there are no folders under "g:\my folder", otherewise, if there are folders in "my

search and replace file names - bug fix

社会主义新天地 提交于 2020-01-06 07:35:09
问题 I have a script that changes particular string within files names (the file stores in "my_folder"): Set objFso = CreateObject("Scripting.FileSystemObject") Set Folder = objFSO.GetFolder("g:\my folder") For Each File In Folder.Files sNewFile = File.Name sNewFile = Replace(sNewFile,"._epf","_v0_1._epf") if (sNewFile<>File.Name) then File.Move(File.ParentFolder+"\"+sNewFile) end if Next the scrpit works fine if there are no folders under "g:\my folder", otherewise, if there are folders in "my

How to change the name of an environment variable with a different variable?

喜欢而已 提交于 2020-01-06 07:28:29
问题 Is there a method to name an environment variable dynamically using another environment variable in a batch file? Something like numplayers=3 char%numplayer%atk=12 echo char3atk with output 12 回答1: It's quite straightforward: SET numplayers=3 SET char%numplayers%atk=12 ECHO %char3atk% 回答2: Given that you are unlikely to know beforehand the number assigned to %numplayers% , here are a few ways you can see the value of the variable: Set "numplayers=3" Set "char%numplayers%atk=12" Call Echo %