batch-file

How to count characters in a text file using batch file

旧巷老猫 提交于 2020-01-17 09:11:08
问题 I want to count all the characters of a certain text. However in my code it only counts single string. But the requirement needs to count all characters including whites spaces and new line.. For example: Hello World! How are you today? Hope you are okay How am i going to do that in my code?Thanks. My code: @ECHO OFF for %%i in (y.txt) do @set count=%%~zi REM Set "string" variable SET string=(Hello World How are you today? Im fine..) // i want to read these string because my code only read

Compare directory name to string

放肆的年华 提交于 2020-01-17 08:36:29
问题 I've created this very simple batch file for the sake of testing a concept I'm hoping to utilize. I need to recursively delete all of one type of file except in folders with a specific name. Here's my code: :recur FOR /f %%a IN ('DIR /b') DO ( IF EXIST %%a\NUL ( IF ["%%a" NEQ "subtest2"] ( ECHO %%a CD %%a CALL :recur CD .. ) ) COPY "*.cfm" "*_copy.cfm" REM DEL "*_copy*.cfm" ) Right now I'm just testing using copy instead of delete. Basically, this should create a copy of all the .cfm files

Expanding variables in a Windows batch file

不羁的心 提交于 2020-01-17 08:14:00
问题 I run the following command in a Windows batch file: start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file 1.pdf" /A "page=4&zoom=55.5" "G:\my pdfs\file 2.pdf" The works perfectly fine and opens both PDF files using their respective parameters. However, to make the process cleaner, I would like to start using variables in place of the PDF files (and even the PDF viewer executable). However, when I use variables, only the first PDF file opens: set PDF1="G:\my pdfs\file

Expanding variables in a Windows batch file

柔情痞子 提交于 2020-01-17 08:13:06
问题 I run the following command in a Windows batch file: start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file 1.pdf" /A "page=4&zoom=55.5" "G:\my pdfs\file 2.pdf" The works perfectly fine and opens both PDF files using their respective parameters. However, to make the process cleaner, I would like to start using variables in place of the PDF files (and even the PDF viewer executable). However, when I use variables, only the first PDF file opens: set PDF1="G:\my pdfs\file

Search and replace text in a txt file by a batch file in Windows

喜欢而已 提交于 2020-01-17 07:56:19
问题 I have a huge file approx 100 mb to 500 mb, it take more time to open it and I cannot change it also due to slow response in Notepad or notepad++. I have requirement to replace only REF Number and this is only one time in the file. Can I have a Batch file/ Script in Command prompt so that I can replace the text? Regards and Thx. 回答1: @echo off set "toreplace=REF" for /f "tokens=* delims= " %%a in (yourfile.txt) do ( set "line=%%a" setlocal enabledelayedexpansion set "line=!line:%toreplace%=!"

Run bat file from java code to get desired result in txt file - no can do :(

青春壹個敷衍的年華 提交于 2020-01-17 07:41:29
问题 I have the following problem. I got a bat file that runs testcomplete test. After the test is finished in testcomplete, the app closes and exit code is passed back to the bat. Still in bat file i create a txt file called result and then depending on exit code i write to it successs, failure etc. When i run that bat file in Windows 7 i can see that test is being executed and after it's finished result.txt file appears with information i need. But when i simply run this same bat file from java

Robocopy and get Copied file name

岁酱吖の 提交于 2020-01-17 07:11:53
问题 I'm using robocopy to only sync only newer file, but I also need to get the file name being copied. I've to further use copied file name to make a entry in a some other file. I wasn't able to found switch, which only displays copied file name, any powershell script of batch file will also be fine. 回答1: This function parses all the RoboCopy text output and outputs that as a nice object. Use it like this: $RoboCopyOutput = robocopy $source $destination /ROBOSWITCHES Parse-RoboCopyOutput

Delete shares excluding C$ D$ ADMIN$… etc

一世执手 提交于 2020-01-17 06:41:05
问题 Have a script in .bat for deliting shares on win7 (without admins shares like ADMIN$ etc.) @echo off (wmic path Win32_OperatingSystem get /value|find "ProductType=1" > nul) || (echo [e] Server OS & goto :eof) setlocal EnableDelayedExpansion for /f "delims=" %%a in ('wmic share get name /value ^| findstr /r /v "^$"') do ( for /f "tokens=2 delims==" %%b in ("%%a") do ( set VarAdminAllowed=NotAllowed for %%c in (ADMIN$ IPC$ print$ fax$ A$ B$ C$ D$ E$ F$ G$ H$ I$ J$ K$ L$ M$ N$ O$ P$ Q$ R$ S$ T$

Batch script not working?

你。 提交于 2020-01-17 06:17:05
问题 @echo off setlocal EnableDelayedExpansion (for %%z in (*.xml) do call :processFile "%%z") >output.txt goto :EOF :processFile set "returnMap=" set "portal=" set /a i=0 for /F "tokens=3,5 delims==> " %%a in ('findstr /C:"<int name=" /C:"<imgdir name=" /C:"<string name=" %1') do ( if not defined returnMap ( if %%a equ "returnMap" ( set "returnMap=[%%~b]" ) ) else ( if not defined portal ( if %%a equ "portal" set portal=true&SET /a i+=1&SET "line=" ) else ( FOR %%w IN (pn pt x y tm) DO IF %%a equ

Input redirects not working with batch file prompts

烂漫一生 提交于 2020-01-17 06:00:02
问题 I have a batch file that I am trying to automate using input redirects from a file. The general idea of the batch file is to copy files over based on a yes or no response. First, the user is prompted which version they would like to pull the files from. Following that, the user is prompted if they would like to install the different files. If the user chooses yes, the next prompt is delayed due to the file being copied. Here as an example of the output: Please enter the release version (ex:53