batch-file

Why does a batch file switching current directory for command prompt not work on using SETLOCAL command?

ε祈祈猫儿з 提交于 2020-01-30 08:22:48
问题 I am running the following batch script from within a command prompt window to go to a specific folder. @echo off SETLOCAL set ispyfolder=true if not "%~1"=="py" if not "%~1"=="pyfolder" set ispyfolder=false if "%ispyfolder%"=="true" ( C: cd C:\Users\ankagraw\AppData\Local\Continuum ) This code doesn't work when SETLOCAL is there (2nd line). The current directory is the same as before running the batch file from within a command prompt window. If I remove this line, then the script works fine

Batch script to rename PDF files using the content

瘦欲@ 提交于 2020-01-30 08:22:06
问题 I have a batch script used to extract PDF information and rename the PDF then. The script is working fine for 1 PDF file but I need to use it directly in a folder with a lot of PDF files. So how to do it? The script needs to run for each PDF file, one by one until the end. Once the PDF file is renamed next the file is moved in another folder, so the PDF file remaining in the folder need the same thing. And when the folder is empty the script exits. @echo off setlocal enabledelayedexpansion

Wait for batch file to finish process in Powershell before executing other commands?

故事扮演 提交于 2020-01-30 07:51:51
问题 I'm trying to execute a Powershell file which needs to execute batch file and once batch file processing completes then only proceed to next command And, batch process shouldn't open a new window. $p = Start-Process $dir\bin\stop.bat -Wait -Passthru $p.WaitForExit() if ($p.ExitCode -eq 0) { java "-Dtar.memoryMapped=true" -Xms8g -Xmx8g -jar oak-run-1.4.6.jar checkpoints $dir\repository\segmentstore | Out-File $log_path\log_checkpoints.txt } I tried above code but it's not working. 回答1: You can

Wait for batch file to finish process in Powershell before executing other commands?

断了今生、忘了曾经 提交于 2020-01-30 07:51:05
问题 I'm trying to execute a Powershell file which needs to execute batch file and once batch file processing completes then only proceed to next command And, batch process shouldn't open a new window. $p = Start-Process $dir\bin\stop.bat -Wait -Passthru $p.WaitForExit() if ($p.ExitCode -eq 0) { java "-Dtar.memoryMapped=true" -Xms8g -Xmx8g -jar oak-run-1.4.6.jar checkpoints $dir\repository\segmentstore | Out-File $log_path\log_checkpoints.txt } I tried above code but it's not working. 回答1: You can

Batch - replacing with percent symbol

好久不见. 提交于 2020-01-30 05:57:52
问题 I want to replace "mod" in string with "%": set string=%string:mod=x% What I should input as "x"? 回答1: you can do that by enabling delayed expansion so you can use ! as delimiters. Then, doubling the percent sign allows to represent percent as a replacement char. @echo off setlocal enabledelayedexpansion set string=12 mod 15 set string=!string:mod=%%! echo %string% result 12 % 15 来源: https://stackoverflow.com/questions/41323488/batch-replacing-with-percent-symbol

Need Windows command file that runs all commands in a folder [closed]

▼魔方 西西 提交于 2020-01-30 03:26:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 months ago . https://www.online-tech-tips.com/computer-tips/create-windows-batch-files/ explains how to create a command (batch) file that opens a set of specific Windows commands. I'd like to generalize this, so I can create folders that contain command shortcuts and run such a folder (using

.bat for batch rename to increment numbers in fname

北慕城南 提交于 2020-01-29 21:37:08
问题 I have a large folder of .cbr's, and I'm renaming them by issue number to correctly order them. What do I need to include in the ren line to have each file increment the number in the file name via windows command prompt? I'll be doing this frequently so I'll make this a .bat file. For example, where n = initial number and m = final number: n.cbr, (n+1).cbr, ..., (m-1).cbr, m.cbr The .bat thusfar: ren *.cbz *.cbr ren *.cbr <increment numbers n through m>.cbr Alternatively, how do I trim each

Bat file to add new line in a certain position in all files inside a folder [closed]

房东的猫 提交于 2020-01-28 03:08:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 days ago . I have a folder with more files .ovpn contain text Path: D:\Program files\config Extension files: *.ovpn I need to add in every files a new line contains mssfix 0 in a certain position in the file mssfix 0 will be added at line 96 or creating a new line at line before resolv-retry

Bat file to add new line in a certain position in all files inside a folder [closed]

江枫思渺然 提交于 2020-01-28 03:07:08
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 days ago . I have a folder with more files .ovpn contain text Path: D:\Program files\config Extension files: *.ovpn I need to add in every files a new line contains mssfix 0 in a certain position in the file mssfix 0 will be added at line 96 or creating a new line at line before resolv-retry

Task Scheduler doesn't execute batch file properly

倖福魔咒の 提交于 2020-01-28 02:25:51
问题 I have a batch file to run a powershell program. When I double click the batch file, it runs the powershell code to generate an EXCEL spreadsheet email this EXCEL spreadsheet I even see this action happening. However, when I use Task Scheduler to execute the batch file, it will run, but it will neither generate an EXCEL spreadsheet, and it certainly won't email the EXCEL spreadsheet. I have created other tasks to run other batch programs to execute powershell programs, and I never had this