batch-file

Check if input is a file or folder

孤街浪徒 提交于 2021-01-29 07:54:44
问题 I have a command like this: set /p txtfile=Write destination to the .txt file: now i need to know if the file really exists so: if exist %txtfile% echo file found. it works, but if the user writes me C:\ it will display "file found" to. I want to know is there a way to know a file extension using batch, any ideas? 回答1: You can identify it as a file using TYPE. However, it might not be the best way if it is a large file. SET "DIR_ITEM=C:\Windows" TYPE "%DIR_ITEM%" 1>NUL 2>&1 IF ERRORLEVEL 1 (

Change font color for batch file log

☆樱花仙子☆ 提交于 2021-01-29 07:45:43
问题 I am executing an exe file from a batch file. This runs a Windows application. Everytime I do some activity in the application, a log gets printed in the batch command prompt. I would like to highlight specific text in the log with colours so that I can pinpoint the backend activity. How do I do this? My batch file looks something like this? cd C:\[Exe file location] C:\[Exe File] pause 回答1: You can create your own echo command. Put the following lines into a file called ColourText.bas on

Configure some variables in command line when calling doxygen

拜拜、爱过 提交于 2021-01-29 07:22:01
问题 I want to generate doxygen documentation with a predefined foo.doxyfile. I want to modify e.g. the PROJECT_NUMBER and generate the documentation with a bat-file. Here is the content of the bat: @echo off setLocal enabledelayedexpansion cls echo Running Doxygen rem Set a lot of variables set BASE_DIR=%~dp0 set "PathToDoxygen=C:\Program Files\Doxygen\bin\doxygen.exe" set "PahtToInterfacesDoxygen=D:\foo\Interfaces\Interfaces.doxyfile" call ( type doxyfile & echo "PROJECT_NUMBER=1.1.2" | "

Use batch file to remove special characters from csv file

不羁岁月 提交于 2021-01-29 07:21:48
问题 I have a csv file with 18 fields. I have written a batch file to manipulate the data. Everything works except removing the comma from the "DEVILS DUE /1FIRST COMICS, LLC" publisher. That field does not parse correctly. I have tried looking at other batch files for examples, but I am not familiar with the snytax. @echo off & Setlocal EnableDelayedExpansion ( FOR /f "tokens=1-18 delims=," %%A in ('More +4 datatest.csv') do ( rem H is the department code rem S is the sales tax code rem Q is the

Batch file datetime windows settings

梦想与她 提交于 2021-01-29 06:02:40
问题 Recently my windows was backed with image restore software to previous version, so I had to install everything from scratch. What really stresses me is that script that had worked before now doesn't. It's related to dates and datetime. My colleague tried to run .bat file and he was able to get appropriate date format. I tried to copy all the windows 10 date settings and still it doesn't work. Any ideas how to solve this? My output is: C:\Software\scripts>for /F "usebackq tokens=1,2 delims=="

Batch - FOR Loop to Turn WMIC Output Into Variable Not Working

南笙酒味 提交于 2021-01-29 03:38:36
问题 I've been trying to turn the output of the following two commands into variables, so that I can use them in a batch file, however I'm not having any luck: WMIC /namespace:\\root\SecurityCenter2 PATH AntiVirusProduct WHERE (displayName="Emsisoft Anti-Malware" or displayName="Emsisoft Internet Security") GET displayName /value WMIC /namespace:\\root\SecurityCenter2 PATH AntiVirusProduct WHERE (displayName="Emsisoft Anti-Malware" or displayName="Emsisoft Internet Security") GET

How do I remove all the lines in a text file that are present in another text file in Windows?

纵饮孤独 提交于 2021-01-29 01:40:17
问题 I have two files: content.txt and remove.txt . I would like to run .cmd script that removes all lines from content.txt that are in remove.txt . The result should go to result.txt . For example: content.txt abc 1234 hello qwerty remove.txt abc hello def result.txt 1234 qwerty This question is the same but using Perl: Removing lines in one file that are present in another file. I can only use standard Windows tools. 回答1: findstr /L /v /X /g:remove.txt content.txt>result.txt /X means "match

How do I remove all the lines in a text file that are present in another text file in Windows?

风格不统一 提交于 2021-01-29 01:36:50
问题 I have two files: content.txt and remove.txt . I would like to run .cmd script that removes all lines from content.txt that are in remove.txt . The result should go to result.txt . For example: content.txt abc 1234 hello qwerty remove.txt abc hello def result.txt 1234 qwerty This question is the same but using Perl: Removing lines in one file that are present in another file. I can only use standard Windows tools. 回答1: findstr /L /v /X /g:remove.txt content.txt>result.txt /X means "match

How to write a batch file to rename files in numerically order within a particular folder?

限于喜欢 提交于 2021-01-28 20:50:45
问题 I have a file contain three pictures, they named ape.jpg, 123.jpg, zoo.jpg I want to write a batch file, it can rename all three pictures into a numerical order. ape.jpg -> (1).jpg 123.jpg -> (2).jpg zoo.jpg -> (3).jpg I don't really care about the original names and orders of those pictures, I know this can be done in any version of windows by manually go into that folder and select them all, rename one of them to (1), and rest of pictures will order themself numerically. but I want to do

Get File name from a variable

霸气de小男生 提交于 2021-01-28 20:26:12
问题 i am totally new to batch file programming so please forgive me if this is plain obvious. Say i have a c:\some\path\someFile.extension string stored in TheFileToPass and i am invoking another exe from the same batch file such that i should only pass it the File name deducted from TheFileToPass (i.e, someFile ). A pseudo code of what i am trying to do: string TheFileToPass = "c:\some\path\someFile.extension" call external_tool.exe TheFileToPass.GetFileNameWithoutExtension() By searching online