部分這裏是我迄今爲止...批處理命令提取的可變
@echo off
@cls
SetLocal EnableDelayedExpansion
del /f /q "c:\setup*.txt" >nul 2>NUL
dir c:\setup.exe /b /s >c:\setup1.txt 2>NUL
rem this gives me a text file like this (without the 'equals' lines):
==================================
c:\oracle\product\9.1.20.1\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_2\oui\bin\setup.exe
c:\oracle\product\11.2.53\client_1\oui\bin\setup.exe
c:\Program Files\Adobe\Reader 11.0\Setup Files\{AC76BA86-7AD7-1033-7B44-AB0000000001}\setup.exe
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft .NET Framework 3.5 SP1\setup.exe
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\Setup.exe
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\SetupCache\Extended\Setup.exe
c:\WINDOWS\system32\setup.exe
c:\WINDOWS\system32\dllcache\setup.exe
===================================
find /i "\oui\bin\setup.exe" c:\setup1.txt >c:\setup2.txt 2>NUL
rem this takes the previous text file and searches for the string "\oui\bin\setup.exe" and gives me a text file like this (without the 'equals' lines):
===================================
---------- C:\SETUP1.TXT
c:\oracle\product\9.1.20.1\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_2\oui\bin\setup.exe
c:\oracle\product\11.2.53\client_1\oui\bin\setup.exe
===================================
more /E +2 C:\setup2.txt >C:\setup3.txt
rem this takes the previous text file, strips the first two lines (top line is blank), and gives me a text file like this (without the 'equals' lines):
===================================
c:\oracle\product\9.1.20.1\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_1\oui\bin\setup.exe
c:\oracle\product\10.2.0\client_2\oui\bin\setup.exe
c:\oracle\product\11.2.53\client_1\oui\bin\setup.exe
===================================
在這一點上,我需要能夠先於\客戶端解壓路徑名稱的一部分.. 。如下:
c:\oracle\product\9.1.20.1\client_1\oui\bin\setup.exe => c:\oracle\product\9.1.20.1
c:\oracle\product\10.2.0\client\oui\bin\setup.exe => c:\oracle\product\10.2.0
c:\oracle\product\10.2.0\client_1\oui\bin\setup.exe => c:\oracle\product\10.2.0
c:\oracle\product\10.2.0\client_2\oui\bin\setup.exe => c:\oracle\product\10.2.0
c:\oracle\product\11.2.53\client_1\oui\bin\setup.exe => c:\oracle\product\11.2.53
我知道如何拉路徑的一部分,減去一定數目的字符從結束,但我只是無法弄清楚如何提取路徑的那部分描述以上。我希望這是有道理的。
Thanx。
有點生疏與批處理,但你可以在循環中嘗試這樣的事情:1.刪除路徑名的最後一個字符; 2.如果最後七個字符==「\ client」,則只返回最後七個字符; 3.如果#2錯誤,返回#1 –