Content Type
Profiles
Forums
Events
Everything posted by Yzöwl
-
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
As long as the person running the script is always using the same locale/system, using find alone will be fine. It's bad enough that we're almost two years into this Topic, but what's even worse is that the questions are being asked without giving those expected to help the overall picture in order that the responses can be structured to suit the end goal and not exact question being asked. I would have thought, based on the assumption that the real file name may not match the cabbed file name, that all files should be in uncabbed state up until the final stages. The following examples uses the same general idea as before, this time do not change anything with it at all, just place it along side the TEST1 directory. Double click them, (one at a time), and read the log file produced. Version using SKIP @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION PUSHD %~dp0 SET "SD=TEST1" SET "OF=_LIST.LOG" >%OF% TYPE NUL FOR /R %SD% %%$ IN (*.*_) DO CALL :SUB1 %%$ GOTO :EOF :SUB1 SET "CF=%*" SET "LD=!CF:*%SD%\=!" FOR /F "SKIP=9 DELIMS=" %%# IN ('CABARC L "%CF%"') DO ( CALL :SUB2 %%# SET _I=!_F:* =! CALL :SUB2 %%_F:!_I!=%% >>%OF% ECHO/!LD!:!_F!) GOTO :EOF :SUB2 SET _F=%* Version using MORE @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION PUSHD %~dp0 SET "SD=TEST1" SET "OF=_LIST.LOG" >%OF% TYPE NUL FOR /R %SD% %%$ IN (*.*_) DO CALL :SUB1 %%$ GOTO :EOF :SUB1 SET "CF=%*" SET "LD=!CF:*%SD%\=!" FOR /F "DELIMS=" %%# IN ('CABARC L "%CF%"^|MORE +9') DO ( CALL :SUB2 %%# SET _I=!_F:* =! CALL :SUB2 %%_F:!_I!=%% >>%OF% ECHO/!LD!:!_F!) GOTO :EOF :SUB2 SET _F=%* (note: files with two or more spaces together will not work because they will not exist in the real world) -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Well I've just tested that script on an outdated Windows 2000 machine by makecabbing a dll file with spaces in the file name and the cabbed file name with spaces in it too. It worked 100% with the version 1 of cabarc I alerted you too earlier. I would suggest that the problem is either due to something you have done to my script when you've tried to implement it for your own purposes or that you are using a file containing two or more spaces together. I'm confident that if file names containing spaces are being used in service packs that there will be none where two spaces exist next to each other -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Why do you need to repack them all, just delete them and you're in the same situation as you would have been if you hadn't uncabbed them in the first place.! BTW, I would suggest that against the 51 seconds your basic routine took to output 2764 lines, that a 5 second, (10%), hit to output just the full file name is pretty darn good. -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
How long would this take then, It's untested because I'm logged into Linux atm @ECHO OFF & SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION FOR /F "TOKENS=*" %%# IN ('CABARC L "abc.dl_"') DO ( CALL :SUB %%# SET _I=!_F:* =! CALL :SUB %%_F:!_I!=%%) ECHO/%_F% PING -n 4 127.0.0.1 1>NUL GOTO :EOF :SUB SET _F=%* BTW, you're only finding out the contents of a service pack once, it is not a common task, therefore a time difference is negligible. Also like I've already stated, the method used to arrive at the exact file name you require with no leading or trailing spaces is what will effect your times, not just the speed of the utility. You also need to understand that your question was how to parse the line from the reading of a single file not an entire directory full of them. Your previous attempt to test the speeds of the utilities indicated only 33 seconds to uncab all of the files, I would therefore suggest it will be much quicker to uncab them all and directory list the resultant files. It shouldn't matter if "a b c.dll" exists fifteen times it can only be updated once, therefore it only needs to be listed once. To overwrite without prompt try 'CABARC X "abc.dl_" Y' or alternatively use the -o switch! -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
In what context? I know that you've already 'attempted' to show that uncompressing files with each utility on every file recursively is slower with expand, but you're only reading the name of the single file contained within this time. You should also be aware that the more involved your method of determining the file name contained within, the more likely it is that you will influence the time taken. What are you trying to get the true expanded file name for? Additionally if using a different version of cabarc.exe you may find more than one line containing a forward slash for the FIND command to pick up. Example -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Have you tried just using 'expand' @ECHO OFF & SETLOCAL ENABLEEXTENSIONS (SET TESTFILE=D:\My Files\abc.dl_) FOR /F "TOKENS=*" %%# IN ('EXPAND -D "%TESTFILE%"^|FIND /I "%TESTFILE%"') DO ( SET _=%%#) ECHO/%_:*: =% PING -n 4 127.0.0.1 1>NUL -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
The example you have provided shows us only that the space has been delimited because it has split the string before it has seen your double quote and output only the first token. See how these work: @ECHO OFF & SETLOCAL ENABLEEXTENSIONS ECHO/DELIMITED DOUBLE QUOTES ONLY FOR /F TOKENS^=1-3^ DELIMS^=^" %%A IN ("THIS IS"ENCLOSED"IN DOUBLE QUOTES") DO ECHO/[%%A] [%%B] [%%C] FOR /F USEBACKQ^ TOKENS^=1-3^ DELIMS^=^" %%A IN ('THIS IS"ENCLOSED"IN DOUBLE QUOTES') DO ECHO/[%%A] [%%B] [%%C] ECHO/&ECHO/DELIMITED DOUBLE QUOTES AND SPACES FOR /F TOKENS^=1-6^ DELIMS^=^"^ %%A IN ("THIS IS"ENCLOSED"IN DOUBLE QUOTES") DO ECHO/[%%A] [%%B] [%%C] [%%D] [%%E] [%%F] FOR /F USEBACKQ^ TOKENS^=1-6^ DELIMS^=^"^ %%A IN ('THIS IS"ENCLOSED"IN DOUBLE QUOTES') DO ECHO/[%%A] [%%B] [%%C] [%%D] [%%E] [%%F] PAUSE & GOTO :EOF -
help to IF NOT EXIST batch command
Yzöwl replied to ZEUS__'s topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Why could you not simply correct the first word after the equals symbol in each of the four cases I provided! I think that it may be you who is misunderstanding OR! You now seem to only want FILE.THREE to be deleted if both of the other two files do not exist. IF NOT EXIST "FILE.ONE" (SET _=BO) IF NOT EXIST "FILE.TWO" (SET _=%_%TH) IF %_%==BOTH DEL "FILE.THREE" So in summary: IF BOTH FILE.ONE AND FILE.TWO DO NOT EXIST use the above example IF AT LEAST ONE OF FILE.ONE OR FILE.TWO DO NOT EXIST use either of the two examples I provided in my original post -
help to IF NOT EXIST batch command
Yzöwl replied to ZEUS__'s topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I'm still not sure what you want! Correct this: FILE.ONE exists + FILE.TWO exists = Keep FILE.THREE FILE.ONE exists + FILE.TWO absent = Delete FILE.THREE FILE.ONE absent + FILE.TWO exists = Delete FILE.THREE FILE.ONE absent + FILE.TWO absent = Keep FILE.THREE -
help to IF NOT EXIST batch command
Yzöwl replied to ZEUS__'s topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
PROBLEMCHYLD, are you suggesting that you do not wish to delete FILE.THREE if neither file exits, only if just one of them doesn't? -
help to IF NOT EXIST batch command
Yzöwl replied to ZEUS__'s topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
A couple of ideas IF EXIST FILE.ONE (IF EXIST FILE.TWO (GOTO :NEXT)) DEL FILE.THREE :NEXT IF NOT EXIST FILE.ONE SET _OR=T IF NOT EXIST FILE.TWO SET _OR=T IF DEFINED _OR DEL FILE.THREE -
Additionally, if you let us know what it is you are trying to do we may be able to provide you with a solution from the console directly.
-
You need to provide more information.
-
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
No not just spaces. Tabs are often used too, but the main thing was the hex string you used. Your automatic routine would need to know how, for instance, the following relate when checking for duplicates 0x00000000 0x0 0 ,, ,<one or more spaces>, ,<one or more tabs>, ,<one or more spaces with one or more tabs>, As for your query about findstr… It's not findstr that's causing you the problem, its thinking through what your goal is before structuring your code.you are not looking for sp.qfe, you are looking for example for sp1qfe\\, sp2qfe\\, or sp3qfe\\. anyhow regardless of that, here is an example script using your search and findstr strings: @ECHO OFF SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION (SET VAR=) FOR /F "TOKENS=*" %%# IN ('FINDSTR/I \\SP.QFE\\ 1.INF') DO SET VAR=%%# IF NOT DEFINED VAR GOTO :EOF CALL :SUB ECHO/gsar -o -s"%VAR%" -r 1.inf PAUSE GOTO :EOF :SUB SET VAR=%VAR:*\\SP=% SET VAR=SP%VAR:~,6% GOTO :EOFRemove the ECHO on line seven to try it when happy with the output! -
Post count limitation hasn't been implemented yet, as with most things it requires discussion, followed by agreement prior to implementation.
-
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Would that be done manually? HKCR, TypeLib\{662901fc-6951-4854-9eb2-d9a2570f2b2e}\5.1, , 0x2, "Microsoft WinHTTP Services, version 5.1" How do you deal with string variables since they use percent characters, do you have to convert them all to another character, then convert them back again later. What happens if a string variable is used from the strings section, and another key contains the same data but without implementing the string variable. How does a non manual method know that? -
How to merge two text files?
Yzöwl replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Here is an idea you may be able to use to help you. @ECHO OFF SETLOCAL ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION FOR /F "TOKENS=*" %%# IN (1.TXT) DO CALL :SUB %%# IF DEFINED _OUT ( >TEMP.TXT ( ECHO/%FIRST% ECHO/%SECOND% ECHO/%THIRD% ECHO/%FOURTH% ECHO/%FIFTH% ) ) GOTO :EOF :SUB SET LINE=%* SET _FIRST=%LINE:*,=% CALL :OUT %%LINE:%_FIRST%=%% SET FIRST=%_OUT:~,-1% SET _SECOND=%_FIRST:*,=% CALL :OUT %%_FIRST:%_SECOND%=%% SET SECOND=%_OUT:~,-1% SET _THIRD=%_SECOND:*,=% CALL :OUT %%_SECOND:%_THIRD%=%% SET THIRD=%_OUT:~,-1% SET _FOURTH=%_THIRD:*,=% CALL :OUT %%_THIRD:%_FOURTH%=%% SET FOURTH=%_OUT:~,-1% CALL :OUT %%LINE:*%FOURTH%,=%% SET FIFTH=%_OUT% GOTO :EOF :OUT SET _OUT=%*I would be interested in your reasons for deconstructing .inf files line by line before reconstructing them. -
My suggestion would be to disallow this 'feature' for those who have not/do not participate in the forums proper. Maybe a post count limitation.
-
Batch to Log & Console
Yzöwl replied to Dogway's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
If you are installing software/applications you cannot expect that each developers installer will have built in an error logging procedure which can be output through a command line interface. For instance, Windows Installer uses the /L switch for logging to a file. In some cases, you may be better advised outputting all to a log file then displaying that output to the console. Also if it is only the error stream you are interested in have you tried changing the tee.vbs to read: set con = createobject("scripting.filesystemobject").opentextfile("con:", 2) do until wsh.stdin.atendofstream s = wsh.stdin.readline wsh.stderr.writeline s : con.writeline s loop -
Batch to Log & Console
Yzöwl replied to Dogway's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Thanks for using the method I provided which uses built-in tools and requires no third party utilities. I will add that I see little point in using a batch file which calls a batch file which calls a utility over one which simply calls a vbscript..One question, have you deliberately removed a section of your script? If not, you're performing tasks for no reason, there is no point in copying a file to a directory then removing that directory -
objShell.Run issues...
Yzöwl replied to Falcor's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
How difficult is the single line batch/comand using WMIC I posted in post 21? -
objShell.Run issues...
Yzöwl replied to Falcor's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
And this from the commandline / batch WMIC CPU GET ADDRESSWIDTH /VALUE|FIND "=64">NUL 2>&1&&ECHO=[64bit]||ECHO=[x86] -
objShell.Run issues...
Yzöwl replied to Falcor's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Using that logic then the following should suffice: ECHO=%PROCESSOR_ARCHITECTURE%' %PROCESSOR_ARCHITEW6432%'|FIND "64'">NUL 2>&1&&ECHO=[64bit]||ECHO=[x86] Alternatively: REG QUERY "HKLM\Hardware\Description\System\CentralProcessor\0" /v Identifier|FIND /I "x86"&&ECHO=[x86]||ECHO=[64bit] -
objShell.Run issues...
Yzöwl replied to Falcor's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Set objShell = CreateObject("WScript.Shell") ProgFilesPath = objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") If Not objFSO.FolderExists(ProgFilesPath) Then ProgFilesPath = objShell.ExpandEnvironmentStrings("%ProgramFiles%") objShell.Run(Chr(34)ProgFilesPath & "\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe" & " -s 192.168.1.201 -u root -p " & RootPassword.Value & Chr(34), 1, False)