batch-file

How to unzip a ZIP archive file using batch file? [duplicate]

三世轮回 提交于 2020-03-03 05:46:11
问题 This question already has answers here : How can I compress (/ zip ) and uncompress (/ unzip ) files and folders with batch file without using any external tools? (3 answers) Closed 2 years ago . I would like to use a .bat file to unzip a ZIP compressed archive file if possible at all. Nothing fancy, I just want to extract the entire archive file to the same location, i.e. download a .zip file to desktop and want to extract it next to desktop with the same name. I tried this, but with no

Batch countdown timer that doesn't clear rest of output?

浪尽此生 提交于 2020-03-02 06:36:31
问题 I am trying to create a batch timer that doesn't clear the output above it. I have a timer function created, but am looking to improve it so that I can still view the output above it without having lines on lines of a countdown in the output. My current function is: @echo off echo KEEP THIS OUTPUT CALL :timer 10 rem Do more things... EXIT :Timer set time=%~1 :loop cls echo Countdown - [%time%] set /a time=%time%-1 if %time%==0 goto timesup ping localhost -n 2 > nul goto loop :timesup echo

Batch countdown timer that doesn't clear rest of output?

放肆的年华 提交于 2020-03-02 06:31:59
问题 I am trying to create a batch timer that doesn't clear the output above it. I have a timer function created, but am looking to improve it so that I can still view the output above it without having lines on lines of a countdown in the output. My current function is: @echo off echo KEEP THIS OUTPUT CALL :timer 10 rem Do more things... EXIT :Timer set time=%~1 :loop cls echo Countdown - [%time%] set /a time=%time%-1 if %time%==0 goto timesup ping localhost -n 2 > nul goto loop :timesup echo

Replace with regular expression using Batch (Windows)

允我心安 提交于 2020-02-29 06:24:06
问题 is it possible to use regular expression for search and replace for a specific text file? I have a text file located C:\content.txt inside text there is google link https://www.google.com/ i need a batch (.bat) script which can replace <https://www.google.com/> to [abc]https://www.google.com/[/abc] here is the notepad++ regex replace Find What: .+(.google\.com).+ Replace with: [abc]$0[/abc] 回答1: You should use Regex in vbscript with a batch file like this code : You can see Regex Demo here

Batch - Get string between first and last double quotes

ε祈祈猫儿з 提交于 2020-02-27 09:53:28
问题 I have a string like this: Testing:"abc"def"ghi" I want to get: abc"def"ghi and put it into a variable, is there any possible way? I want a general way of doing that (first and last quotes, not first and fourth quotes) 回答1: This will work reliably as long as the string does not contain unquoted special characters like & | > < ^ @echo off set str=Testing:"abc"def"ghi"extra echo str = %str% set "new=%str:*"=% echo new = %new% -- OUTPUT -- str = Testing:"abc"def"ghi"extra new = abc"def"ghi

Passing Parameter From Batch File to Powershell?

时光毁灭记忆、已成空白 提交于 2020-02-26 04:02:07
问题 I am trying to create a form which passes variable values for 1.CustomerID and 2.EmailReceiver into a batch file. I then want the Customer ID to be sent to a Sub-Procedure and produce reports (this is working) and have the EmailReceiver value sent to a PowerShell file. However when i try to pass the %EmailReceiver% value to the Powershell file it doesn't seem to work. I have the following Code. Batch File Code: <!-- : for /f "tokens=1 delims=," %%a in ('mshta.exe "%~f0"') do ( set "CustomerID

How to delete files end with a substring and older than N days

北城以北 提交于 2020-02-26 00:52:28
问题 I want to delete extensionless files older than 7 days whose names end with _C . Example files: B_C_A1_C B_C_A2_C B_C_A3_A test.txt My code: SET mypath=%cd%\downloads ForFiles /p %mypath% /d -7 /c "cmd /c del /q %mypath%\*_C When I execute the code, it deletes all files which contains _C , but I want to delete only files which end with _C and are older than 7 days. How can I fix this? 回答1: For more information about the forfiles documention, see Batch file to delete files older than N days.

Use batch script to insert a string at a particular line in XML

穿精又带淫゛_ 提交于 2020-02-25 06:40:08
问题 i am new to programming. Can some1 kindly teach me how to insert a new line in an XML file using batch script? Current file has first 2 lines: <?xml version="1.0"?> <Workbook xmlns="urn:schemas-microsoft-com:xxxxxxxxx I want to add a format string on Line 2 so it has: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:xxxxxxxxxx It has to be using batch-file as the rest of the file is built with it. Cheers, Alan 回答1: @echo off setlocal

Naming network drives from commandline rather than Windows Explorer

让人想犯罪 __ 提交于 2020-02-24 20:55:10
问题 I'm writing a batch file to map multiple servers to drives on my PC. Using the NET USE command, I have managed to map the drives successfully. When viewed in Windows Explorer, each drive shows the letter assignment and the server name. I'd like to display a user-friendly plain-English name for each server in the Explorer view also (this is different from the volume label). I can right-click on each drive individually in Explorer and rename but this is a bit long-winded. Is there any way that

How to get the name of calling bat script

℡╲_俬逩灬. 提交于 2020-02-24 17:27:25
问题 I need to have my 2.bat script behaviour depending on the name of calling script. Scenario: 2.bat is invoked from many other external scripts, which I am not entitled to change. Only 2.bat is under my thumb. 1.bat : ... call 2.bat 2.bat : ...here place something extracting "1.bat"... 回答1: As you cant change the calling bat there will be almost impossible to get its name if it is triggered through the cmd console (may be a memory dump could help?) as then the ProcessId will hold information