batch-file

Windows command line compression/extraction tool?

一世执手 提交于 2020-01-24 20:40:35
问题 I need to write a batch file to unzip files to their current folder from a given root folder. Folder 0 |----- Folder 1 | |----- File1.zip | |----- File2.zip | |----- File3.zip | |----- Folder 2 | |----- File4.zip | |----- Folder 3 |----- File5.zip |----- FileN.zip So, I wish that my batch file is launched like so: ocd.bat /d="Folder 0" Then, make it iterate from within the batch file through all of the subfolders to unzip the files exactly where the .zip files are located. So here's my

Using >nul in a variable

泄露秘密 提交于 2020-01-24 19:50:21
问题 Does anyone know how to stop >nul being ignored when set in a variable, or is this not possible? I have a feeling that it's one of those things that will only work once all variables have been expanded or something, but it can't hurt to ask. Example: @echo off :: Won't work SET pause_5=ping localhost /n 6 >nul %pause_5% :: Will work SET pause_5=ping localhost /n 6 %pause_5% >nul exit 回答1: Put quotes around the argument: set "pause_5=ping localhost /n 6 >nul" Another option is to escape

With Windows batch file, how to parse a file and output part to one file, part to another?

不问归期 提交于 2020-01-24 19:50:13
问题 I'm a Perl programmer, but I need to do a Windows batch file for a particular task. The script needs to read an input file line by line, and copy to an output file. However part way through, it needs to switch output files. For reading an input file and outputing to a file generally, the solution in the following article by Jeb seems to work best. (Other solutions don't work well when the input data has weird characters or long lines) Batch files: How to read a file? However I can't get it to

separate day month and year from a date batch file

Deadly 提交于 2020-01-24 17:40:29
问题 when i do echo %date% i get output as pet 28.06.2013 other dates pon -> monday tor -> tuesday sre -> wedneday cet -> thursday pet -> friday sob -> saturday ned -> sunday I wrote following batch file to get the day month and time. but its not working. please help/ FOR /F "tokens=1-3 delims=." %%A IN ("%sample%") DO ( SET day=%%A SET month=%%B SET year=%%C ) echo %day% echo %month% echo %year% output pet 28 06 2013 I want the output as 28 06 2013 回答1: Use "tokens=2-4delims=. " Note the SPACE

separate day month and year from a date batch file

被刻印的时光 ゝ 提交于 2020-01-24 17:40:07
问题 when i do echo %date% i get output as pet 28.06.2013 other dates pon -> monday tor -> tuesday sre -> wedneday cet -> thursday pet -> friday sob -> saturday ned -> sunday I wrote following batch file to get the day month and time. but its not working. please help/ FOR /F "tokens=1-3 delims=." %%A IN ("%sample%") DO ( SET day=%%A SET month=%%B SET year=%%C ) echo %day% echo %month% echo %year% output pet 28 06 2013 I want the output as 28 06 2013 回答1: Use "tokens=2-4delims=. " Note the SPACE

Count Var in Windows Batch

一曲冷凌霜 提交于 2020-01-24 15:28:26
问题 In my batch file I have the following variables: set collection=collection1 set environment=oracleDev set processChain1=-help,-startimport %environment% %collection% As you can see, my process chain contains two strings that are separated with a ",". Now I want to count the two strings (later it could be more then one string). I tried it with: Set count=0 For %%j in (%%processChain1%%) Do Set /A count+=1 echo %count% But there is the first mistake. It prints out 1 and not 2. Why? After

Count Var in Windows Batch

感情迁移 提交于 2020-01-24 15:28:21
问题 In my batch file I have the following variables: set collection=collection1 set environment=oracleDev set processChain1=-help,-startimport %environment% %collection% As you can see, my process chain contains two strings that are separated with a ",". Now I want to count the two strings (later it could be more then one string). I tried it with: Set count=0 For %%j in (%%processChain1%%) Do Set /A count+=1 echo %count% But there is the first mistake. It prints out 1 and not 2. Why? After

How do I run a batch file with WinExec?

时光怂恿深爱的人放手 提交于 2020-01-24 14:05:04
问题 I'm using Windows 3.11, and in answer to a question about running batch files with certain attributes, someone suggested using WinExec . How do I do that? Is there something special to do because it's a batch file instead of a normal program? 回答1: Starting a batch file with WinExec is the same as starting anything else with WinExec . The first parameter is the command line to run, and the second parameter is the window-display parameter, indicating how you'd like the new program's window to

Run cmd command work but run from batch file doesn't

梦想的初衷 提交于 2020-01-24 12:38:32
问题 I try to create script with for loop to move file to sub folder. At the beginning, I work with CMD then I copy command to .bat file and run it. The result is nothing happens. Why the same command on CMD works but run from file not ? Here is my command. @echo off setlocal enableDelayedExpansion SET FOL=J:\test SET ENDNUM=2 for /l %x in (1, 1, %ENDNUM%) do ( md "%FOL%/0%x/subfolder" move /Y "%FOL%\0%x\*" "%FOL%\0%x\subfolder" ) 回答1: You have to double-up the percentage signs on for commands in

Stop build and display message with Build Events

会有一股神秘感。 提交于 2020-01-24 12:01:05
问题 I am using the Build Events with Microsoft Visual Studio Express 2012 to copy some files into the $(TargetDir) . How can I stop the build if a particular file isn't found. Currently I have something like: IF EXIST somefile ( ECHO true ) ELSE ( ECHO false ) With displays true and false to the build output dialog as appropriate but I'd like to replace ECHO false with ELSE ( ECHO somefile was not found exit ) Where exit stops the Visual Studio from building the project and somefile was not found