batch-file

How do you match an exact file extension under Windows/command line/file open dialog?

孤人 提交于 2021-01-01 04:52:33
问题 I am trying to get a directory listing of only files with a given extension. At first blush this seems to be a simple thing to do, however check out this simple example: C:\CODE\metcal>dir /b *.exe metcal.exe metcal.exe1 Notice that this returns metcal.**exe** and metcal.**exe1** as matches. With python files a similar thing happens: C:\CODE\metcal>dir /b *.py metcal.py metcal.pyc Notice again Windows has determined that *.py takes anything that starts with *.py so it captures the .pyc files

Open file by dragging and dropping it onto batch file

柔情痞子 提交于 2020-12-31 22:00:13
问题 You know how if you drag and drop a files icon over a program or shortcut to a program it will open the file with that program? Well I have a batch that opens a program and what I want it to do is take a file that was dragged and dropped onto the batch files icon and open that file with the program the batch is pointing to. Is there any batch script that can do that? The reason I want to do this is that I have multiple files next to multiple shortcuts and I want to have those shortcuts just

Open file by dragging and dropping it onto batch file

不打扰是莪最后的温柔 提交于 2020-12-31 21:37:25
问题 You know how if you drag and drop a files icon over a program or shortcut to a program it will open the file with that program? Well I have a batch that opens a program and what I want it to do is take a file that was dragged and dropped onto the batch files icon and open that file with the program the batch is pointing to. Is there any batch script that can do that? The reason I want to do this is that I have multiple files next to multiple shortcuts and I want to have those shortcuts just

How to loop over environment variables in windows batch file? [duplicate]

拈花ヽ惹草 提交于 2020-12-26 09:27:02
问题 This question already has answers here : Arrays, linked lists and other data structures in cmd.exe (batch) script (10 answers) Closed 12 days ago . In windows, I want to loop over a set of environment variables like in this pseudo code: set MYVAR1=test set MYVAR2=4711 set MYVAR3="a b c" for /l %%x in (1, 1, 3) do ( echo %MYVAR%s%% ) for which I expect the following output test 4711 a b c How to change this example code to get it to work? 回答1: @echo off set MYVAR1=test set MYVAR2=4711 set

How to loop over environment variables in windows batch file? [duplicate]

旧时模样 提交于 2020-12-26 09:24:49
问题 This question already has answers here : Arrays, linked lists and other data structures in cmd.exe (batch) script (10 answers) Closed 12 days ago . In windows, I want to loop over a set of environment variables like in this pseudo code: set MYVAR1=test set MYVAR2=4711 set MYVAR3="a b c" for /l %%x in (1, 1, 3) do ( echo %MYVAR%s%% ) for which I expect the following output test 4711 a b c How to change this example code to get it to work? 回答1: @echo off set MYVAR1=test set MYVAR2=4711 set

“rem” comment in .bat file causes error “25 was unexpected at this time”

无人久伴 提交于 2020-12-25 16:00:15
问题 Isn't this weird? Do .bat rem commands have some kind of escape code? file.bat: rem https://sourceforge.net/p/jedit/bugs/4084/?limit=25 Running it: C:\Users\admin>file.bat 25 was unexpected at this time. C:\Users\admin>https://sourceforge.net/p/jedit/bugs/4084/?limit=25 I don't see any errorlevel. 回答1: The rem command supports one argument, namely /? , and it is greedy for it. Your URL contains that string. The = is a standard token separator (just like SPACE , TAB , , , ; ), and so the

“rem” comment in .bat file causes error “25 was unexpected at this time”

自闭症网瘾萝莉.ら 提交于 2020-12-25 15:59:48
问题 Isn't this weird? Do .bat rem commands have some kind of escape code? file.bat: rem https://sourceforge.net/p/jedit/bugs/4084/?limit=25 Running it: C:\Users\admin>file.bat 25 was unexpected at this time. C:\Users\admin>https://sourceforge.net/p/jedit/bugs/4084/?limit=25 I don't see any errorlevel. 回答1: The rem command supports one argument, namely /? , and it is greedy for it. Your URL contains that string. The = is a standard token separator (just like SPACE , TAB , , , ; ), and so the

“rem” comment in .bat file causes error “25 was unexpected at this time”

谁都会走 提交于 2020-12-25 15:58:49
问题 Isn't this weird? Do .bat rem commands have some kind of escape code? file.bat: rem https://sourceforge.net/p/jedit/bugs/4084/?limit=25 Running it: C:\Users\admin>file.bat 25 was unexpected at this time. C:\Users\admin>https://sourceforge.net/p/jedit/bugs/4084/?limit=25 I don't see any errorlevel. 回答1: The rem command supports one argument, namely /? , and it is greedy for it. Your URL contains that string. The = is a standard token separator (just like SPACE , TAB , , , ; ), and so the

How can I exit a batch file from within a function?

大城市里の小女人 提交于 2020-12-24 05:48:51
问题 I have a simple function written to check for directories: :direxist if not exist %~1 ( echo %~1 could not be found, check to make sure your location is correct. goto:end ) else ( echo %~1 is a real directory goto:eof ) :end is written as :end endlocal I don't understand why the program would not stop after goto:end has been called. I have another function that uses the same method to stop the program and it work fine. :PRINT_USAGE echo Usage: echo ------ echo <file usage information> goto

How do I pass variable when using Python subprocess module

眉间皱痕 提交于 2020-12-21 04:23:36
问题 I'm trying to use python Subprocess module to enable/disable Ethernet connection from python code. Below is my code in which the first step is looking for the available "Ethernet Connections" and the next step enables/disables the ethernet connection according to the parameter passed in "%interfaces%". for /f "skip=2 tokens=3*" %%A in ('netsh interface show interface') do set interface=%%B netsh interface set interface %interface% ENABLED Now when using in python I couldn't pass the variable,