batch-file

Pass environment variables to subshell CMD

放肆的年华 提交于 2020-01-05 06:48:38
问题 I have a problem in my gitlab-ci.yml on Windows. I launch phpunit with environments variables. So, I have a variable like: PHPUNIT : %SOURCE_PATH%\cgi-bin\php.exe %PHPUNIT_PATH% And some variables are declared before: SOURCE_PATH: 'C:\Source' PHPUNIT_PATH: '"%SOURCE_PATH%\cgi-bin\tests\__init\tools\phpunit.phar"' But when I use the CALL command, Windows doesn't resolve the variable inside the other variable. So if I do: CALL Echo %PHPUNIT% I have: C:\Source\cgi-bin\php.exe "%SOURCE_PATH%\cgi

change to directory after searching for the file via DIR

為{幸葍}努か 提交于 2020-01-05 06:45:26
问题 Outcome is to change to directory after searching for the file via DIR through cmd Location of file is C:\Folder is the following code possible? set /a variable= dir document.doc /s /p cd %%variable%% Change directory to C:\Folder 回答1: try this: for /f "delims=" %%# in ('dir document.doc /s /b') do ( set "new_dir=%%~dp#" ) cd /d "%new_dir%" 回答2: Run in a command prompt window set /? and read the output help carefully from first to last page. set /A is for evaluating an arithmetic expression .

Batch rename file using for loop

让人想犯罪 __ 提交于 2020-01-05 06:44:05
问题 I am trying to use a for loop to rename a file ::@Echo Off setlocal enableDelayedExpansion ::Set Date set mydate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2% ::Rename file for %%F in (D:\Data\*.bak) do ( ren %%F D:\Data\prod_live_Full_%mydate%0000.Lts.bak ) I keep getting invalid command error. Any help is appreciated. 回答1: When modifying files in a directory use a static file list from dir instead of a dynamic file list from for . Otherwise, you will get stuck in an infinite loop. @echo Off setlocal

win batch regexp search and replace

爷,独闯天下 提交于 2020-01-05 06:39:31
问题 I have a set of data like this 7859 10000:00 7859 10000:00 (xfer#1, to-check=1033/1035) 32768 000:17 22174479 10000:00 (xfer#2, to-check=1032/1035) They are read from a file and passed line by line to a method inside my batch script What I want to do in that method is to extract only 7859 22174479 from this lines, basically whatever is after "\d+:\d\d\s+", then what follows are the numbers that I need and then another "\d\d.*" Is this possible using only batch script regular expression and

Convert Unicode file to ANSI using Bat file

此生再无相见时 提交于 2020-01-05 06:27:35
问题 I need to convert a unicode text file (19,000K) to an ANSI text file for use with Essbase. I currently have this written to convert the file but only the first 7800 lines are copying. This is what I have in my .bat file cmd /a /c TYPE PVTBHFM_20160708.dat > PVTBHFM_ANSI.dat What am I missing to fully convert this file? Is there a way to save the file in a different location? 来源: https://stackoverflow.com/questions/38274847/convert-unicode-file-to-ansi-using-bat-file

Batch script for loop not working

∥☆過路亽.° 提交于 2020-01-05 05:49:09
问题 I need to have multiple remote admins test their download speeds at site. Speedtest.net and alike aren't a true indicator of performance in our WAN. I don't wish to use iperf as I need to minimise the technical knowledge and effort of the remote admins. I don't want them to have to install anything either. Therefore I need a simple batch file to download a test file 5 times. This is what I have so far: @echo off rem localize variables to this script setlocal rem delete the test file if it

Batch file - date variables and moving files with variable date file name from one folder to another

元气小坏坏 提交于 2020-01-05 05:48:06
问题 I need some assistance, please. I'm trying to create a batch file to move files from one folder to another. The file name will have variable yyyy-mm format plus additional data before or after the date. The batch will need to move the file to a server directory with the same mmmm-yy folder name. I've come up with the code below, but it doesn't quite work. A "Missing Operand" error is returned. The new directory is created but the files are not moving from the old folder to the new one. My

How to process 2 FOR loops after each other in batch?

南笙酒味 提交于 2020-01-05 05:47:13
问题 My problem is that two FOR loops are working separately, but don't want to work one after another. The goal is: The first loop creates XML files and only when the creation has already been done the second loop starts and counts the size of created XML files and writes it into .txt file. @echo off Setlocal EnableDelayedExpansion for /f %%a in ('dir /b /s C:\Users\NekhayenkoO\test\') do ( echo Verarbeite %%~na jhove -m PDF-hul -h xml -o C:\Users\NekhayenkoO\outputxml\%%~na.xml %%a ) for /f %%i

Drag and drop batch file equivalent in Linux [closed]

时光毁灭记忆、已成空白 提交于 2020-01-05 05:45:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am currently able to run files through my python script via a .bat file. The contents of this batch file is simply: C:\Python26\python.exe mypythonfile.py %1 pause I can drag and drop various files onto the .bat file and the python script will execute, using the dropped file as the argument...using sys.argv

How do you run a command line program (like lame or svn) with PHP?

穿精又带淫゛_ 提交于 2020-01-05 05:42:44
问题 Specifically, I need to automate the encoding of audio files into mp3 with LAME. You don't need to know LAME to answer this, I could be talking about svn or some other program.. I know how to use LAME on the command line to do this, for one file at a time. I would like to do this via a php script however, so I can convert a bunch at once (for instance, all the files in a directory) So what I am confused about, is how I should invoke the program, LAME. I could definitely use shell_exec() http: