batch-file

multiple IF else conditions issue

橙三吉。 提交于 2020-03-05 04:00:35
问题 I have an issue where I want to segregate / split file based on search item into multiple files. if I see add I want to put that line to addfile . similar to changeprop , insert and if I cannot find any match then to otherfile . I'm unable to process the if else conditions. FOR /F "tokens=* delims=" %%a in ('TYPE "%File%"') DO ( SET "eachline=%%a" IF /i "!eachline:~0,3!" == "ADD " (ECHO !eachline!>>"%ADDActionScriptsMergedFile%") ELSE ( IF /i "!eachline:~0,9!" == "ADDINSERT" (ECHO !eachline!>

Run a batch file from its parent directory in NotePad++

ぃ、小莉子 提交于 2020-03-05 00:30:42
问题 I made a batch file that identifies java files kept in that particular folder and compiles them. But when I was running it from notepad++, the batch file was going to notepad++ working directory i.e. C:\Program Files\Notepad++ , and then starting, so I was not getting desired output. <Command name="Java_Executor" Ctrl="no" Alt="no" Shift="no" Key="0">"D:\Projects\Java\Executor Java.bat"</Command> I tried to edit it many times but didn't got desired output. <Command name="second try" Ctrl="no"

Output in Reverse in CMD

亡梦爱人 提交于 2020-03-04 16:38:27
问题 I have a phrase that needs to be outputted in results.txt. The phrase comes from x.txt. For example: "I have two kids", it should output "kids two have I" in results.txt. UPDATE Its already working but i want no loop. Pls see code below Code @ECHO OFF set /p content=<x.txt SET var=!content: =,! SET rev= :LOOP IF NOT "!var!"=="" ( FOR /F "delims=, tokens=1,*" %%F IN ("!var!") DO ( SET rev=%%F,!rev! SET var=%%G ) ) ELSE ( SET rev=!rev:~0,-1! GOTO ENDLOOP ) GOTO LOOP :ENDLOOP ECHO !rev:,= ! >

making a variable dynamic in if statement

别说谁变了你拦得住时间么 提交于 2020-03-04 15:35:53
问题 I am trying to do the bellow: setlocal enabledelayedexpansion set choice= set /p choice="Select File Number, or no to exit: " if "%choice%"=="no" ( goto cleanup ) else ( set "!choice!=%choice%" start %file!choice!% pause ) what i want is to open a file where the variable is %filex% and be able to choose what file to open 来源: https://stackoverflow.com/questions/60470710/making-a-variable-dynamic-in-if-statement

making a variable dynamic in if statement

≡放荡痞女 提交于 2020-03-04 15:35:30
问题 I am trying to do the bellow: setlocal enabledelayedexpansion set choice= set /p choice="Select File Number, or no to exit: " if "%choice%"=="no" ( goto cleanup ) else ( set "!choice!=%choice%" start %file!choice!% pause ) what i want is to open a file where the variable is %filex% and be able to choose what file to open 来源: https://stackoverflow.com/questions/60470710/making-a-variable-dynamic-in-if-statement

BATCH - Find string in text file and add a new string after that line

老子叫甜甜 提交于 2020-03-04 07:05:23
问题 I'm trying to search a text file for a particular string from a bat file. If the string exist, add a new string after it on the next line. I can't seem to get the code below working correctly. Any Ideas? This is the string i'm searching for in my text file. [/Script/MyGame.Mode] Here's what the text file looks like. [/Script/Config.Mode] Something here 1 Something here 2 [/Script/MyGame.Mode] Something here 1 Something here 2 [/Script/Edit.Mode] Something here 1 Something here 2 And here's

I am trying to get the Date and Time (on a variable) of the most recently modified file in the Logs folder but I always get an error

无人久伴 提交于 2020-03-04 05:06:44
问题 I am trying to get the Date and Time (on a variable) of the most recently modified file in the Logs folder but I always get an error ('was unexpected at this time.') I am using the following code: @echo off SETLOCAL for /f %%G in ('dir .\Logs /b/a-d/o-d/t:w') do ( if not defined NewestFileTime ( set NewestFileTime=%%~tG ) else ( if %NewestFileTime% GTR %%~tG set NewestFileTime=%%~tG ) ) if not defined NewestFileTime ( echo There is no file in current directory. goto :exit ) echo Last file

I am trying to get the Date and Time (on a variable) of the most recently modified file in the Logs folder but I always get an error

不打扰是莪最后的温柔 提交于 2020-03-04 05:06:31
问题 I am trying to get the Date and Time (on a variable) of the most recently modified file in the Logs folder but I always get an error ('was unexpected at this time.') I am using the following code: @echo off SETLOCAL for /f %%G in ('dir .\Logs /b/a-d/o-d/t:w') do ( if not defined NewestFileTime ( set NewestFileTime=%%~tG ) else ( if %NewestFileTime% GTR %%~tG set NewestFileTime=%%~tG ) ) if not defined NewestFileTime ( echo There is no file in current directory. goto :exit ) echo Last file

Unabled to determine java version when running .bat command from within Qt installer

孤人 提交于 2020-03-03 12:16:10
问题 I would like to detect if java has been installed on a machine, and if so which JRE version. I have a simple .bat file script that runs and queries the registry. This works okay when run alone but when run within the Qt installer the same command returns no key, value pairs. I am a bit stumped. I have tried elevating the installer when executing the command, but frankly the script succeeds when running without privileges from the command, and it also did not make a difference. For instance,

Unabled to determine java version when running .bat command from within Qt installer

拜拜、爱过 提交于 2020-03-03 12:14:05
问题 I would like to detect if java has been installed on a machine, and if so which JRE version. I have a simple .bat file script that runs and queries the registry. This works okay when run alone but when run within the Qt installer the same command returns no key, value pairs. I am a bit stumped. I have tried elevating the installer when executing the command, but frankly the script succeeds when running without privileges from the command, and it also did not make a difference. For instance,