This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 5151. |
Solve : displaying file inside the directory ??? |
|
Answer» Hello everyone , where can i put directory inside the dir command dir /s "directory" dir /w "directory" dir /b "directory" dir /s /b "directory" take your pick. directory can have wild cards e.g. "directory\*.txt" Quote from: emuhulk on September 12, 2009, 06:57:16 AM thank you it is working Code: [Select]for /f "delims==" %%A in ( ' dir /b directory\*.bat ' ) do ( echo Do you want to run %%~nA settings ) |
|
| 5152. |
Solve : Set Var=?? |
|
Answer» Thank you thank you thank you. Is there a way around this to force it to take the actual location of the bat file so I can remove it? the filename + extension of a batch file is contained in the variable %0 (percent zero). The full name would be %~dpnx0 so, adding quotes in case the path and/or name has spaces, del "%~dpnx0" would make a batch delete itself, but you would get an error message because you have deleted the running batch from within itself. Ok, so %0 gives me the whole path, but what is the ~dpnx REFER to? or is that like sending commands to the delete command? Ok, I think I found something. I did Call /? in a command prompt and find %~dp1 - expands %1 to a drive letter and path only, but still confused on the nxThey are standard variable modifiers. If you typed for /? at the command prompt, didn't you see this? %~I - expands %I removing any surrounding quotes (") %~fI - expands %I to a FULLY qualified path name %~dI - expands %I to a drive letter only %~pI - expands %I to a path only %~nI - expands %I to a file name only %~xI - expands %I to a file extension only %~sI - expanded path contains short names only %~aI - expands %I to file attributes of file %~tI - expands %I to date/time of file %~zI - expands %I to size of file they can be combined to get compound results: %~dpI - expands %I to a drive letter and path only %~nxI - expands %I to a file name and extension only %~fsI - expands %I to a full path name with short names only so if %0 is a batch file's own name and extension, then %~d0 is its drive letter with a colon %~p0 is the full path to its folder %~n0 is its bare name without extension %~x0 is its extension with a dot before in front of it (usually .bat or .CMD) Put them together adding quotes in case the path has spaces and you get: "%~dpnx0" Thank you for the explanation. |
|
| 5153. |
Solve : what is wildcard character ? is * or ' '? |
|
Answer» Hello everyone , |
|
| 5154. |
Solve : Formatting FOR Loop Value? |
|
Answer» Hi All, How's the project coming Cameron?All done (well kinda). Have finished preliminary testing and all is working as it should. The task is an sftp monitor and transport script using Bitvise's sftpc.exe application. Intent is that files come to a sftp server (where this script is located) from a HP-UX box. This script will monitor for the existance of a trigger file and when found, attempts to CONNECT and push the received 'data' file (received prior the trigger) to a remote sftp service. This is to maintain PCI complience - Both the HP-UX server & Remote SFTP server have Security POLICY & Practises that neither allow direct transfer (push & pull) of data .. and the same type of direct transfers are not permitted under PCI. I've just to code the clean up after each transfer (won't take long). And then to wait on the guys in Europe to get their end ready for some end-to-end testing. Cheers, Cameron |
|
| 5155. |
Solve : I need help with the "IF" command? |
|
Answer» Ok well today I tried using two variables inside the "IF" command and checking to SEE if one variable is larger then the other, it of course is rigged for one variable, yet I continue to have it say that the smaller numbered variable is higher and continueing as if it never did the math it just went with the "goto" code at the end of the which ever "if" statement was first. |
|
| 5156. |
Solve : Certutil? |
|
Answer» Hello all, |
|
| 5157. |
Solve : How to read a text file (Line by Line) using DOS?? |
|
Answer» Hi Everyone, |
|
| 5158. |
Solve : [SOLVED] redirecting output? |
|
Answer» oh, that's nice ooops No, my bad, I forgot I had edited it twice (I can't remember what I wrote first!)I think the answer is, that you know where the echo command ends but cmd.exe does not ECHO hiya >doesnotexist\notextfile.txt 2>error.txt it THINKS this is the filename to echo hiya into: doesnotexist\notextfile.txt 2>error.txt But this way it KNOWS (ECHO hiya >doesnotexist\notextfile.txt) 2>error.txt ahhh yes. The assumption "what I know, it knows". I FALL quite a few times in that. |
|
| 5159. |
Solve : 2 Handy Tips? |
|
Answer» These are for Windows 2000/XP/Vista From my experience, you don't need to create the log file first. Where did I say that you did? It depends (OBVIOUSLY) on what you want to do. If you want to create a new file each time, overwriting any other with the same name, then you WOULD use the > symbol. If you want to create a file if it does not yet exist, OR add text to the end if it does already exist, you would use >>. Nice tips |
|
| 5160. |
Solve : using FOR /R and XXMKLINK to make shortcuts - syntax trouble? |
|
Answer» Hi, I'm trying to make a batch file to make .lnk shortcuts to all of my music collection. |
|
| 5161. |
Solve : How do I "force" machine to boot from CD via a DOS command?? |
|
Answer» This is something I've spent days on the Net TRYING to get the answer to... |
|
| 5162. |
Solve : can we run more than three scripts at a time? |
|
Answer» Hi, I have few ".vbs" scripts, in general i am using batch file to run them by placing ok first you would have to BUILD the scripts into applications Quote if i place in this way all the scripts are running but they are running in sequence like script1 then script 2 etc. yes this is possible by simply saying Code: [Select]start "script1" start "script2" etc. Quote is there any way we can run them in paralle? no srry, commands in batch cant be run similtaneously, because DOS reads batch files SEQUENTIALLY |
|
| 5163. |
Solve : Determining what is in a text file via batch? |
|
Answer» Hi all, how would i go about making a batch file that reads a text file, and if the text file contains a certain word, execute a certain action? Findstr takes a file or receives an input via a pipe as Sidewinder's example shows.yup, so using type would be unnecessary , not that its a big deal anyway Quote from: ghostdog74 on May 16, 2008, 09:14:21 AM I am sure findstr takes in a file as input findstr /I "String to search" filename.txt>nul && execute_commandThanks all, you've been really helpful |
|
| 5164. |
Solve : Copying Windows text into DOS program? |
|
Answer» Hello ! |
|
| 5165. |
Solve : Serious help with BAT?? |
|
Answer» Quote from: Helpmeh on September 02, 2009, 05:13:41 AM Lol.or C# or C++ (classes)Quote from: smeezekitty on September 01, 2009, 05:29:59 PM time to get back on the topic Yeah, everytime i try these codes they open a command prompt briefly and then it closes and no programs open? Any more ideas?Quote everytime i try these codes they open a command prompt briefly and then it closes and no programs open smeezekitty is such an expert, (we are all in his thrall) I'm surprised his code does that! FINALLY! I FIGURED OUT HOW IT'S DONE!!!!!!!!!!! Okay, everyone listen close. I saved the BAT in the same FOLDER with the game, edited the file name, and I entered into the bat: start BAR.exe edomdog IT WORKED! THANKS ANYWAY FOR ALL YOUR CONSIDERATION THOUGH!Quote from: TNovelist on September 12, 2009, 09:15:53 AM I saved the BAT in the same folder with the game 4 pages. Quote from: Salmon Trout on September 12, 2009, 09:22:36 AM 4 pages. Look, I'm sorry. I just screwed up again. I tried making a copy of the bat file and reediting the code in it to make my game run fullscreen and I changed the names of the bat. Now it says, "BAT.exe not found." when I try and run it. So I GUESS this forum thread isn't over. Sorry, just fixed it again. There was a space in the file name.Quote from: TNovelist on August 30, 2009, 09:30:21 AM Okay, so u mean: Put edomdog inside quote marks after Barney's Asylum Reloaded.exe. EDIT: Ooo I posted this a bit late. |
|
| 5166. |
Solve : Can i undo changes made to my dos-program? |
|
Answer» No SOURCE code.Quote from: gabrieltire on May 21, 2008, 05:50:44 AM No source code.But can you TELL which database product is used to hold your data ? GrahamI believe it uses a btrieve file.http://www.pervasive.com/support/technical/btrv615/btr61dos.pdf Anyone out there who has experience with btrieve files? |
|
| 5167. |
Solve : Check If Variable Contains Anything But Numbers? |
|
Answer» I have a batch program that you run like: since you are using a hybrid, you can do checking easily with vbscript function called IsNumeric(). use it somewhere before the Wscript.Sleep() line... Thanx I'll try that after! |
|
| 5168. |
Solve : Capture multiple selected File Names in Text File? |
|
Answer» Hi All, For eg.: If i select 10 files, this post-processing command is repeated 9 times. Is this always true? For instance if you select 5 files, do only 4 get passed? Seems odd that it would stop working when the parameters are no longer addressable. If that's true then this piece of code won't help, but hey you never know! Code: [Select]@echo off for /f "tokens=* delims=" %%v in ("%*") do ( set str=%%v ) set /a count=1 :top for /f "tokens=%count%" %%v in ("%str%") do ( echo %%v >> names.txt call set /a count=%%count%%+1 goto top ) :out echo %saspath% -sysin F:\share\Manohar\pgm\chklog_asg.sas %options% >> names.txt Perhaps to can give us more info on how this batch file is connected to explorer and what prompts it's execution. Hi, Thanks! for your reply. But the issue still exists. To give you idea about how this batch file is executed, I went to Tools->Folder Options->File Types->.sas( SAS Program) -> Advance -> ChkLog(menu item) I have following command pasted : F:\Share\Manohar\copy.bat "%1" in action perfomed box. What I basically want to do is get names of selected .sas programs, execute them and check their log files. When I run your code below is the OUTPUT I am getting "F:\Share\manohar\v_adhy.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adfb.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adfh.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adhb_29feb.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adhb_sure.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon You can see that chklog_asg.sas program is selected multiple times. All I want is to be selected once and that too at the end. Is it has to do with %1 parameter which I pass in action performed box. I even tried to remove that %1 but windows by defualt enter it again. Please provide your input. Thanks!I seem to remember to something a similar way back. For some REASON the "%L" variable was used on the command line in Windows. Try using open in the action box and in the application used to perform action box USE "F:\Share\Manohar\copy.bat" "%L". And make sure the DDE box is checked. Seems the %L is a system variable used in Windows Explorer. Hi, Thanks! again for your reply. But no LUCK. It still executes the :out code n number of times. The output still is: "F:\Share\manohar\v_adhb_29feb.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adfb.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon "F:\Share\manohar\v_adfh.sas" "C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin F:\share\Manohar\pgm\chklog_asg.sas -nosplash -icon Not sure which batch file you're using. (yours or mine posted earlier). In any case add a pause statement at the end, make sure echo is off, and post the console listing. Something does not make sense; if each file selected is run thru a batch file separately, there should be n number of post processing commands, not n-1. If the files are submitted to the batch file as a group then I can find not an error in your original logic. Maybe the console list will give us some insight. |
|
| 5169. |
Solve : copy data step by step? |
|
Answer» I am new to the batch scripting. Can anyone plz tell me what would be the script of following task I am new to the batch scripting. Can anyone plz tell me what would be the script of following task 1. Put in floppy disc into drive [ready for copy] ( There is no software command for this task ) C:\>D: D:\>copy *.* c:\temp_floppy\ Quote from: billrich on September 11, 2009, 07:29:43 AM 1. Put in floppy disc into drive [ready for copy] I think he means display a message to the user to insert a DISK Code: [Select]@echo off :loop cls echo Insert a floppy disk and then set /p dummy=press ENTER to start copying copy a:\*.* c:\temp_floppy set /p again="Do you want to copy another disk [Y/N] ? " if /i "%again%"=="Y" goto loop Thanks mate, your script is working Actually i m working on project, two more things are yet to do. Can you help me out plz 1. Enter new Directory name b. Confirm new Directory by [Y /N] 2 - Generate list of folder and file on particular directory 1. Code: [Select]:loop set dirname= set /p dirname="Enter directory name ? " if /i "%dirname%"=="" ( echo Error: empty input. echo. goto loop ) echo. echo You entered %dirname%. :check set /p correct="Is this correct [Y/N] ? " if /i "%correct%"=="Y" goto next if /i "%correct%"=="N" ( echo. goto loop ) echo Error: type Y or N only! echo. goto check :next 2. DIR directory really APPRECIATE your time and effort... but still the required task is not done In FIRST task, the entered folder name is not being created actually and in second task how to generate a list of text files and directories with that command.. will be waiting thanxQuote from: Adeel on September 13, 2009, 07:37:37 AM but still the required task is not done 1. You did not say you wanted to create a directory. Study the mkdir command. 2. To learn how to make a list of files and directories, study the dir command. Quote from: Adeel on September 13, 2009, 03:56:07 AM Actually i m working on project, two more things are yet to do. This wouldn't be a school project would it? |
|
| 5170. |
Solve : Answering yes when a bat file runs? |
|
Answer» I am building a bat file to setup .net framework to run. When the command runs it ask if you are sure, it has a y & n. I want it to select y and run from there. does the .net framework install file support command line switching??? CHOSE = command 1 needs. Andrew, I think you meant Choice.com from DOS, NOT "CHOSE" Besides that, I don't think choice will help llightsey out here. blastman & Sidewinder both have viable suggestions that llightsey should pursue first. This is the bat file i want to run, when it runs it ask if i am sure and I answer YES. I don't want to type the yes in how can I make it auto answer the question and run? Bat file to allow a PC to run .net programs color 0a @cls c: cd \windows cd microsoft.net cd Framework cd v2.0.50727 CasPol.exe -m -ag 1.2 -zone Intranet FullTrust set set PERSIS=/PERSISTENT:YES pauseDid you research if there is a silent switch? You can try the pipe but there are no guarantees: Code: [Select]c: cd \windows\microsoft.net\Framework\v2.0.50727 echo Y | CasPol.exe -m -ag 1.2 -zone Intranet FullTrust set set PERSIS=/PERSISTENT:YES pause If the program is expecting the fullword YES, then echo YES instead of Y. Any reason the set statement is after the program execute? Sidewinder, it still wont run unless you type the YES inWell, like I mentioned, not all programs take input from the pipe. Unless you can find a switch for the program to run silently, you may SOL. Have you tried running the program from the Windows run box? Code: [Select]"c:\windows\microsoft.net\Framework\v2.0.50727\CasPol.exe -m -ag 1.2 -zone Intranet FullTrust set" It might be interesting to see if the shell gets activated for the prompt. You can set PERSIS anytime either temporarily thru the batch shell or permanently thru Windows. Good LUCK. I got it working I found the switch that TURNS the question off New Code Bat file to allow a PC to run .net programs color 0a @cls c: cd \windows\microsoft.net\Framework\v2.0.50727 CasPol.exe -pp off -m -ag 1.2 -zone Intranet FullTrust Just change the _pp on and it will agin ask you It's always good to hear to success STORY. Thanks for all your help on the Fourm Sidewinder |
|
| 5171. |
Solve : using telnet in a batch file? |
|
Answer» Greetings, |
|
| 5172. |
Solve : A simple batch file, lots of confusion? |
|
Answer» Heya, I'm back. I've been studying up a bit on my coding and programming and someone asked me a question. The question was "Could that remote shutoff denial program you made be reversed to close explorer?". I shrugged and said something along the lines of "Probably, but I'd just write something different.". Eventually the curiosity overcame me and I tried it. It didn't work. My code is as follows:
No rush on getting back to me. At least this time I gave it some thought. If this won't work, is it possible to create a file that runs only when explorer is opened?when you say, "explorer" do you mean the windows explorer or the internet explorer???Quote Bugs/issues:If you end the Explorer.exe process, you can expect to 'screw' up your COMPUTER. What exactly are you trying to accomplish by doing this?Quote from: blastman on June 02, 2008, 07:55:09 AM when you say, "explorer" do you mean the windows explorer or the internet explorer???Windows explorer. Quote from: Carbon Dudeoxide on June 02, 2008, 07:56:35 AM
HRM... I guess Media Player -should- close? That may be a hint to a problem on this computer then. Usually when I close explorer through things LIKE task manager, most other programs remain running. Yes, folders close, but programs usually remain open. Ideally, only explorer should close. As for what I'm trying to accomplish, I just want to see if it can be done. My friend NATE asked and I want to see if it can be done. |
|
| 5173. |
Solve : Resize Partition...? |
|
Answer» I have windows XP SP2. How can I resize my hard drive partition using DOS ?NTFS or FAT? Ya, I get blue screen error when I resume from standby. nd also sometimes my system gets hanged up while i'm playing games or doing other work. It is likely that your hard disk is about to fail or that at least one stick of your ram is already defective. If it is the former then you may be about to lose all files on your hdd. Please get back and tell us that your backup is secure. Download and run the diagnostics program from your hdd manufacturers site, if the program indicates a failure then you have no alternative to replacing your hdd. Also d/l & run Memtest86 from Memtest.com. If you get another bsod post the ENTIRE error message not just what you remember of it. Good luck. |
|
| 5174. |
Solve : how run command prompt without displaying black screen? |
|
Answer» hello everyone , To emuhulk well actually- it's a one liner in both vb6 and vbscript.Quote from: emuhulk on September 12, 2009, 08:33:40 PM forum that i tought it can help to develope my project for my internship. See now it's homework and that's frowned upon in here. If it's homework then ask and explain exactly what it is YOU have done to find the answer. I love google but it costs my neighbours a lot of money to keep me on the internet..Download the app in the attatchments I made, drag a batch file onto it or run like: INVISIRUN.exe PROGRAM.bat It will run the batch program invisible. ----------------------------------------------------------------------------------------------------------------------------------------------- http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html Free compiling software to convert .bat to .exe, you can click Invisible Application to make it invisible. ----------------------------------------------------------------------------------------------------------------------------------------------- Do not use Invisirun.exe for HAX0R batch files as I am not responsible for any damage caused to any comps. elel302 [attachment deleted by admin]Quote from: elel302 on September 13, 2009, 08:59:57 AM Download the app in the attatchments I made, drag a batch file onto it or run like: INVISIRUN.exe PROGRAM.batPlease delete that post. |
|
| 5175. |
Solve : Help please!!!!!!!? |
|
Answer» Hi, I'm new here, so hi everyone! |
|
| 5176. |
Solve : Memory Map HELP? |
|
Answer» Quote from: nymph4 on May 15, 2008, 12:26:14 PM Am I CORECT that you would need both EMM386.EXE and HIMEM.SYS to use Extended Memory? Yes. The HIMEM.SYS line must appear before the EMM386.EXE DEVICE line in CONFIG.SYS. This thread looks like you are studying for your A+ certification. I hope you are not doing all your learning on web forums! Quote from: Dias de verano on May 15, 2008, 12:36:14 PM Quote from: nymph4 on May 15, 2008, 12:26:14 PMAm I corect that you would need both EMM386.EXE and HIMEM.SYS to use Extended Memory? To emulate EXPANDED memory, yes, to use extended memory no- Otherwise the 286 would have NEVER been able to use extended memory, since it can't use EMM386. (which might explain the name) And the EMM386 program can be run standalone, and will give some information and/or change settings when passed switches. why, I even fired up my old thinkpad just for you guys emm386 when run as a command gives me this: IBM Expanded Memory Manager 386 Version 4.50 Copyright (c) IBM Corp. 1986, 1994 Expanded memory services unavailable. Total upper memory available . . . . . . 0 KB Largest Upper Memory Block available . . 0 KB Upper memory starting address . . . . . . B000 H EMM386 Active. and probably my most used command usually, mem /c, gives: [t]MODULES using memory below 1Mb: Name Total = Conventional + Upper Memory -------- ---------------- ---------------- ---------------- SYSTEM 22,928 (22K) 9,616 (9K) 13,312 (13K) HIMEM 768 (1K) 768 (1K) 0 (0K) EMM386 3,392 (3K) 3,392 (3K) 0 (0K) V7320MGR 2,096 (2K) 2,096 (2K) 0 (0K) V7320APM 1,696 (2K) 1,696 (2K) 0 (0K) DOSKEY 1,152 (1K) 1,152 (1K) 0 (0K) MOUSE 24,576 (24K) 272 (0K) 24,304 (24K) COMMAND 3,424 (3K) 0 (0K) 3,424 (3K) FDREAD 160 (0K) 0 (0K) 160 (0K) ANSI 3,600 (4K) 0 (0K) 3,600 (4K) MWDP0400 2,032 (2K) 0 (0K) 2,032 (2K) FREE 742,416 (725K) 636,352 (621K) 106,064 (104K) Memory SUMMARY: Type of Memory Total = Used + Free ---------------- ----------- ----------- ----------- Conventional 655,360 19,008 636,352 Upper 152,896 46,832 106,064 Reserved 240,320 240,320 0 Extended (XMS) 7,340,032 380,928 6,959,104 ---------------- ----------- ----------- ----------- Total memory 8,388,608 687,088 7,701,520 Total under 1Mb 808,256 65,840 742,416 Total Extended (XMS) 7,340,032 (7,168K) Free Extended (XMS) 6,959,104 (6,796K) Largest executable program size 635,376 (620K) Largest free upper memory block 67,856 (66K) Available space in High Memory Area 3,568 (3K) PC DOS is resident in the high memory area.[/tt] |
|
| 5177. |
Solve : checking service status? |
|
Answer» Hi,
OK but it should be %val% Quote Could you kindly tell me what is wrong with the following. |
|
| 5178. |
Solve : can i open a dos program without ............? |
|
Answer» HI all, just wondering if its possible to install and open a dos program without having windows installed and if so how? thanksYes...you could have DOS installed on the hard drive to handle the DOS program on the CD or Floppy. Best version of DOS is 6.22 for its features and compatability. If you dont have this you can buy a OEM install set of about 4 or 5 floppies off of ebay, or if you want a free solution you can use FREEDOS which is open source at http://www.freedos.com/ http://www.freedos.org/ Here is the ACTUAL URL to FREEDOSgreat stuff thanks for all your help! If using W95/8, ME or XP (but not 2000) make a start-up floppy. copy EDIT &c from C:\WINDOWS\COMMAND.The suggestions given are all on track, but I'm curious. Are you working with an older COMPUTER that doesn't have windows installed? Or are you TRYING to get an older DOS program running that doesn't seem to run from Windows? |
|
| 5179. |
Solve : Can you make a batch file save a notepad file?? |
|
Answer» Hi all. |
|
| 5180. |
Solve : echo %name% displays echo is off message ????? |
|
Answer» hello REM Displays echo is of message Seems to work for meQuote from: emuhulk on September 10, 2009, 12:48:13 PM actually what happens is that when put echo inside if statemet it doesnt display ANYTHING it says echo is off if you are using parentheses you need to study delayed expansion. Search this forum or use Google. Quote from: emuhulk on September 10, 2009, 03:52:01 AM hello Maby %name% has no value or was not set properly. |
|
| 5181. |
Solve : Loading From A Different Folder.? |
|
Answer» Well, i have stopped the whole loading from a .TXT file, and i am now loading by seeing if the file exists. So far i have this: i have this: Code: [Select]if EXIST data\level4.txtallready tried it, it doesn't work.Are you sure you are doing it properly? It works for me. Try the drive letter and full path. Remove the first slash if the data folder is under the folder you are in when you run the batch if EXIST data\level2.txt Provide the full drive letter and path, with quotes if any part has spaces if EXIST "C:\My Files\Jacob\whatever\data\level2.txt" That should always work. ---------------------------------------- This will NEVER work. Only 1 IF test per line! I don't know why you put == in there! Code: [Select]if EXIST level3.txt ==if EXIST level2.txt ( Thanks Very Much, I had to do "data\" instead of "\data\"Quote from: DIAS de verano on May 31, 2008, 04:39:24 AM
it does, its saying that both of them have to exist so if you want level 3 the level 2 and level 3 files have to be in there. instead of just having one level 3 file. It seems to work and i have tested it.Quote from: Jacob on May 31, 2008, 04:50:47 AM It seems to work and i have tested it. Yes it does! I never knew you could do that. Sorry! Quote from: Dias de verano on May 31, 2008, 04:57:03 AM Quote from: Jacob on May 31, 2008, 04:50:47 AMIt's fine, looks like we helped each other, at first i tried && with no success i then tried == and woula!.It seems to work and i have tested it. Thanks Again |
|
| 5182. |
Solve : How run a vb script inside a Ms dos batch script?? |
|
Answer» I have this .bat file script but the sent.vbs is not executing inside the bathc. |
|
| 5183. |
Solve : Complicated batch file? |
|
Answer» What I need is a batch file that can delete CERTAIN folders when given ANSWERS to certain questions. |
|
| 5184. |
Solve : Renaming files in a folder depending on size and order? |
|
Answer» Hello, I am new to this list and hope to find some help with this. Also it is a "group" ( for example test_72.*) of the files that is of no interest as they have a max total of 25 Kb, can they be sorted out and be removed from the process? Is this possible with a bat file to calculate total size of a group of files with the same name (except for the file type) and remove it, if it is below a specified size? It could be done, but I would suggest a separate script. Do one thing at a time, do it very well and then move on. PS. The files get named properly, but a copy operation leaves the original files in place for the next run. Not knowing your operation, this might be a problem with duplicating data.Yes many thanks to you it works, but the problem is that this folder has other files as well and they will also be processed. So my fix was to copy the files I needed to a temporary folder and from there use your script. It seems that I can't add new lines to your script, like: D: CD Testfiles COPY test*.* C:\temp\99\test*.* C: CD temp\99 Rename *.TMP *.DAT Do I need another Bat file for doing this or is it possible to put new lines of codes before and after your script? If that is the case how do I activate another bat file within another? Thanks I used the "Call" function and it works. Now I just need to test and change a few settings. Thanks, it was of great help. The file size thing I have to live with for a while, I can remove it manually. Sidewinder, is it possible to change the numerical order so it starts with "0" instead of "1" then I can fix the problem more easily and don't need to remove the files. It now works perfect when I copied the files to a new folder (so I have only those files I need to edit) and run the script from there. ThanksSoli004, A couple of thoughts: Change set /a lines=1 to set /a lines=0 near the top of the script. You don't need to copy the files to another directory. Try filtering the files returned from the dir command with the same mask you used for your copy instruction: Code: [Select]for /f "tokens=* delims=." %%v in ('dir /a:-d /b d:\testfiles\test*.*') do ( About sizing the files. You'd need to hold each group in memory until it's determined whether to keep or discard the group. You can use the %%~zv variable within the second for loop for your calculations. It's not necessary to do all the work from a single script. Simple really is BETTER. PS. I could swear that set lines=%%j+1 should be replaced by set /a lines=%%j+1, but neither you nor I report an error. Strange. Sidewinder, Works as a charm, this is great. removing the files is easier now when they are set to number 0, I can just put a few lines of "Del" and they are gone. All this has made me think of the final goal that I thought was not possible by using batch commands, perhaps I underestimate the potential of using batch Ok last call, I need to add (create) to each group a txt file that has a few lines of text (same text for every file) ending with ".TAB" For the moment I have 50 prepared .TAB files in a special folder that I copy to D:/updates in the script so each time I have 50 .TAB files when I perhaps only need let say 10 or less. This is the text that need to be into each .TAB file for each group. So if there is 10 groups of files it has to be 10 files with this text included (example line1.TAB, line2.TAB etc...). !table !version 300 !charset WindowsLatin1 Definition Table Type NATIVE Charset "WindowsLatin1" Fields 1 Vagnamn Char (80) ;There were a few ways to approach this. An in-memory array would work, but I chose to create a temporary tab file which could be simply copied and renamed accordingly: Code: [Select]@echo off setlocal > c:\temp\tab.dat echo !table >> c:\temp\tab.dat echo !version 300 >> c:\temp\tab.dat echo !charset WindowsLatin1 >> c:\temp\tab.dat echo. >> c:\temp\tab.dat echo Definition Table >> c:\temp\tab.dat echo Type NATIVE Charset "WindowsLatin1" >> c:\temp\tab.dat echo Fields 1 >> c:\temp\tab.dat echo Vagnamn Char (80) ; set /a lines=1 for /f "tokens=1-3 delims=e." %%i In ('dir /o:-n /a:-d /b d:\updates') do ( set /a lines=%%j+1 goto out ) :out set /a count=0 for /f "tokens=* delims=." %%v in ('dir /a:-d /b d:\testfiles\test*.*') do ( call :group "%%v" ) del c:\temp\tab.dat :group call set /a count=%%count%%+1 if %count% GTR 4 ( set /a count=1 copy c:\temp\tab.dat d:\updates\line%lines%.tab > nul call set /a lines=%%lines%%+1 ) for /f "tokens=1-2 delims=." %%w in ("%1") do ( copy d:\testfiles\"%1" d:\updates\line%lines%.%%x > nul ) Quote perhaps I underestimate the potential of using batch Actually many users over estimate the potential of using batch and end up complicating tasks that are better suited to other scripting languages. Good luck. Sidewinder, Thanks but unfortunately its not working completely. The result I get is following for the tab file. ************************** !version 300 !charset WindowsLatin1 Definition Table ************************** I can not see why it jumps (not writing) over !table and the last 3 text rows. Is the spaces before the txt (last 3) a problem? I did try to see if that had something to do with it and removed the spaces but that did not work either. Any clue?I'm not getting your result. In fact I was just congratulating myself on how well this works. The tab file creation logic at the top of the script requires a single > character in the first line and double >> in all the other lines. Echo itself is transparent enough to accept most characters. Guessing the lines with stars were posted for effect and are not part of the tab file. To debug, eliminate all the script except the top code where the tab file is created. You should be able to narrow down any error. If you copied/pasted the code, a stray character may have been picked up which is affecting the interpreter. If you retyped the code and you type like me, all bets are off. Coding is a bore. The real fun comes when you start debugging. Coding is a bore. The real fun comes when you start debugging. For me good coding is a work of art, I have SEEN just a few lines be making magic. You are correct again (as usual) something happened when copy and paste, I could not see it but it helped re-typing it THANKS. The only final "problem" I just find out is that the last "group" does not get a "tab" file. test_0 to test_19 has a ".tab" but test_20 does not? Can you see this... or have I messed up again?Quote Can you see this... or have I messed up again? You didn't mess up, but it does make me wonder how I let this get by. First and last record PROCESSING is usually the most problematic. Code: [Select]@echo off setlocal > c:\temp\tab.dat echo !table >> c:\temp\tab.dat echo !version 300 >> c:\temp\tab.dat echo !charset WindowsLatin1 >> c:\temp\tab.dat echo. >> c:\temp\tab.dat echo Definition Table >> c:\temp\tab.dat echo Type NATIVE Charset "WindowsLatin1" >> c:\temp\tab.dat echo Fields 1 >> c:\temp\tab.dat echo Vagnamn Char (80) ; set /a lines=1 for /f "tokens=1-3 delims=e." %%i In ('dir /o:-n /a:-d /b d:\updates') do ( set /a lines=%%j+1 goto out ) :out set /a count=0 for /f "tokens=* delims=." %%v in ('dir /a:-d /b d:\testfiles\test*.*') do ( call :group "%%v" ) del c:\temp\tab.dat :group call set /a count=%%count%%+1 if %count% GTR 4 ( set /a count=1 call set /a lines=%%lines%%+1 ) if %count% EQU 4 ( copy c:\temp\tab.dat d:\updates\line%lines%.tab > nul ) for /f "tokens=1-2 delims=." %%w in ("%1") do ( copy d:\testfiles\"%1" d:\updates\line%lines%.%%x > nul ) Quote For me good coding is a work of art It will be interesting when you revisit this code in the future (and you will) if you see art or just scratch your head in wonderment. Sidewinder, I just want to thank you for an exellente solution. Everything is working smoothly with no errors, saving me from lots of copying and renaming files manually. Salute |
|
| 5185. |
Solve : how i move a file with batch file ?? |
|
Answer» hi move "%1" "D:\my folder"Dias's suggestion should do it for you. I am curious though. 1. Why do you want to "MOVE" executable files so often that you need it added to the right-click? 2. Are you sure that you want to "MOVE" the executable files? Or did you mean "COPY" them? You will NOT be able to use them for their original intended purpose if you "MOVE" them.Quote move "%1" "D:\my folder"dont work :- whats problem ? hey llmeyer1000 move is e.g i want for other purpose ...Quote from: Mental on May 17, 2008, 08:21:16 AM Quotemove "%1" "D:\my folder"dont work :- It will work if you do it properly. Quote from: Mental on May 17, 2008, 08:21:16 AM hey llmeyer1000 Please explain "other purpose" and your windows version. I can't imagine any useful purpose for moving executable files. I'm not going to help you screw around with your friends if that is your purpose. Also, what did not work with Dias's command line? What were the error messages? We can't figure out what is wrong without information, which you refuse to give. Answer the questions I posted earlier.Quote It will work if you do it properlymaybe ! Quote Please explain "other purpose" and your windows version. I can't imagine any useful purpose for moving executable files. I'm not going to help you screw around with your friends if that is your purpose.i was writen one app for sony ericsson , in new version i want my app easily for use !! so i decide put one option in right click ... my app work on THM files but maybe some one dont have this file but all have exe file (for help me) ... im using sp3 Quote Also, what did not work with Dias's command line? What were the error messages?i dont know ! without error massage , just for moment cmd screen open then quicly it closed !! ((sorry for my english))What is in c:\test.bat? Quote from: Mental on May 17, 2008, 12:57:52 PM im using sp3Does that mean Windows XP SP3? The reason we ask is that certain commands are not available in all versions of Windows, and may also work a bit differently in one version than another. Quote from: Mental on May 17, 2008, 12:57:52 PM QuoteAlso, what did not work with Dias's command line? What were the error messages?i dont know ! without error massage , just for moment cmd screen open then quicly it closed !! Add one or more pauses to your batch file so that you can read the error message before the CMD Window closes. Example: Code: [Select]@echo off move "%1" "D:\My Folder" pause exit Have you already created the destination folder? If not, your code should look more like this: Code: [Select]@echo off md "D:\My Folder" move "%1" "D:\My Folder" pause exit Remove the pause after debugging the batch file. OK, I tried the code with the pause as I suggested. You are right. It does not work. ( Sorry Dias ) Plus the error message is rather cryptic. Quote The syntax of the command is incorrect.This is the problem. %1 is already in quotes by default. You must not add them, or the command will fail with the error above. The following code does the job with or without the destination folder being present. Code: [Select]@echo off if not exist "D:\My Folder" md "D:\My Folder" move %1 "D:\My Folder" Thx llmeyer1000 & Dias de verano, it work for me without " " in the batch file @Dias may you test it without " " (in the batch) and tell me your result ? ThxQuote from: Dias de verano on May 17, 2008, 02:02:17 PM What is in c:\test.bat? Dias, a lot is lost to us because of Mental's English. I missed much of what he has meant in several of his posts.(including in this thread.) After reading through the thread several times, I think I finally understand most of it. Mental, Is the following explanation of "What I "THINK" you meant" ACCURATE? "NOTHING" was in Mental's "test.bat" at the start of this thread. He wanted to know how to use the name of the executable file in the batch file "c:\test.bat" He was trying to show us how he intended to add an action to the right click, and then perform some action on the file. (Moving it was only an example.) If I DECIPHERED it correctly, all he really wanted to know was this. Quote How do I use the name of the file I just right-clicked on in the action file "c:\test.bat"?The answer should have been: Quote The filename you just right-clicked on is represented by the environment variable %1 in the action you just called. (In this case it is "c:\test.bat".)Quote "NOTHING" was in Mental's "test.bat" at the start of this thread. He wanted to know how to use the name of the executable file in the batch file "c:\test.bat"yeah exactly |
|
| 5186. |
Solve : I need to check the number of parameters given for batch submit..? |
|
Answer» Hi All, In this program i am submitting the each parameter to the SAS session in batch mode, is there any way to check the number of parameters given and putting that in a loop like .. do i= 1 to (num of parameter) end Nine parameters are addressable, however you can exceed that limit by shifting the parameter list down (right to left). Doing so, moves the tenth parameter into the ninth spot and the first parameter is dropped from the list. Code: [Select]@echo off set count=0 :start if .%1==. goto next set /a count=%count%+1 shift goto start :next echo %count% arg(s) were passed The code above is a SNIPPET for counting the parameter list. You MAY find it helpful in your code. Good luck. |
|
| 5187. |
Solve : to change file name? |
|
Answer» suppose that i have following file (at leaast 100 files) does the number part have always 2 figures? yes so is it possible to do by DOS Command is there a possibility to have two files withe diffrunt prefix and same suffix like that 03-c.pcl 04-c.pcl so that when u delete the prefix from the name u will have two files with the same name in the same directory and have the same ext which is impossible if no u can use these dos commands for /f "tokens=1,2 delims=-" %%i in ('dir /b *.pcl') do rename "%%i-%%j" "%%j1" for /f "tokens=1,2 delims=." %%i in ('dir /b *.pcl1') do rename "%%i.%%j" "%%i.pcl" u have to rename the file twice to avoid INFINITE loop |
|
| 5188. |
Solve : Running winzip with dos? |
|
Answer» Does anyone know what the following COMMANDS do? |
|
| 5189. |
Solve : Breaking FOR Loop? |
|
Answer» HI Again Everyone, In batch code, is it possible to force a break out of runnng FOR loop ? I've not been able to figure this out (If it is at all possible)Code: [Select] @echo off set MonitorLoops=9 set MonitorInterval=2 for /l %%i in (1,1,%MonitorLoops%) do ( echo Loop %%i of %MonitorLoops% . ping -n %MonitorInterval% 127.0.0.1 > nul if %%i EQU 4 exit ) Any ideas ?? Cheers, Cameron Solved ... just needed to use the GOTO statement. Code: [Select] @echo off set MonitorLoops=9 set MonitorInterval=2 for /l %%i in (1,1,%MonitorLoops%) do ( @echo Loop %%i of %MonitorLoops% . ping -n %MonitorInterval% 127.0.0.1 > nul if %%i EQU 4 goto :Break1 ) :Break1 @echo End-of-Script. Why don't you just set MonitorLoops=4 in the first place? Or was that just to demomstrate the question? Hi Dias, The eventual code won't be checking MonitorLoop. It'll be actually checking for the existance of a 'trigger' file. If it exists, then I need to exit the loop. The example code (excluding the "if %%i EQU 4 goto :Break1" ) would run for 18 seconds. Nine(9) loops with two(2) second intervals between loops. This will eventually be set to have an interval of 300 seconds when it goes into production. Unfortunately I rearely have a chance to create Batch scripts, hence I'm quite rusty. Very grateful for fellas like Sidewinder for their assistance. I HAPPEN to do more of my scripting on HP-UX systems. But thanks for the question anyways. Cheers, Cameron That code will ***never*** get to 5 Hi Dias, Correct - I was deliberately generating a TRUE condition for testing. Cheers, Cameron |
|
| 5190. |
Solve : Echo line in next to last line of file? |
|
Answer» I got an idea last night for a file but they key to it is I need it to echo a line not at the end of the file, but next to last. I can do it that way or i could make it echo say, on line 25 and then move the current line 25 down a line. how do i do either of these?Hey Gamerx, Do you have an example of what you mean?well i didnt want to reveal my idea yet but i guess. I am working on a BATCH AI Interface. What I need it to do is when you ask an unrecognized question it will ask you what you want the response to that question to be, and then it would echo this line inside of a label towards the end: |
|
| 5191. |
Solve : How much should a DOS partition be?? |
|
Answer» Hi, Keep it small if all you are doing is learning, maybe 5 % -10 % of you HD. 20 MB used to be considered a large HD. If you made it the smallest available partition size it would probably be way more than that. The PART of it is, when it comes to basic DOS commands. I don't KNOW crap. When it comes to format C: /s. I understand. When it comes to Killdisk, I understand. How much Megs is 5%? Such as is it 2000 or 3000 or etc?Quote from: php111 on May 29, 2008, 04:03:35 PM How much Megs is 5%? Such as is it 2000 or 3000 or etc? It is 5% of your disk size. Or 1/20 of your disk size. (Whatever that is.) You know your disk size. We don't know your disk size. Quote from: php111 on May 29, 2008, 04:03:35 PM How much Megs is 5%? Such as is it 2000 or 3000 or etc? How large is the HD you are using? If it is say 40 GB, then 5% is 2GB. (40 x .05 = 2) In an earlier post you mentioned that you were TRYING to learn DOS 6.22. Quote I have a dual boot setup with XP Pro and MS-DOS v6.22. How can I learn some or all things about DOS such as my commands and so on? 2 GB is huge in DOS 6.22 world. And now that I remember, 2GB is also the maximum size allowable for a FAT(16) partition for DOS. What partitioning software are you going to use? Look on the site BC_Programmer told you about in an earlier post. www.vetusware.com Utilities section: Partition Magic 4 It's an older version, but may still be adequate for you. (Maybe not, depending the HD size and type of partitions already installed.) |
|
| 5192. |
Solve : creating a batch file to merge two files into one? |
|
Answer» HI, I want to create a batch file that will merge two files, LET's CALL them data_1.txt and data_2.txt into one single data.txt file. I'm lacking slightly in my knowledge of commands so if someone could point me in the right direction that would be GREAT! THANKS in advancecopy data_1.txt+data_2.txt data_3.txtPerfect! Thank you |
|
| 5193. |
Solve : Could not run batch file by double-click? |
|
Answer» I am using Windows Server 2003. |
|
| 5194. |
Solve : Writing the results of a DOS program to a file? |
|
Answer» macdad, I don't think you understand what oba is TRYING to do.yes i dont know wat oba wants accomplished here yes i dont know wat oba wants accomplished here In this code, he is looking into the folder F:\sqldata\MSSQL\BACKUP\master\ and all of its subfolders, and copying any .BAK file that may be there to the folder C:\master. He is making dir SORT its output in reverse date order, why, I do not know. Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:-d /s /b F:\sqldata\MSSQL\BACKUP\master\*.BAK') do ( copy %%i "\\C:\master" goto endmstr1 ) :endmstr1 Here, he is deleting every file in every subdirectory below the directory Z:\master\. This time the dir output is sorted in date order, again, I do not know why. Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:d /s /b Z:\master\*.*') do ( del %%i goto endmstr2 ) :endmstr2 His eccentric use of labels is intriguing. These 2 pieces are exactly EQUIVALENT to the above quoted code sections. Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:-d /s /b F:\sqldata\MSSQL\BACKUP\master\*.BAK') do copy %%i "\\C:\master" Code: [Select]for /f "tokens=* delims=" %%i in ('dir /o:d /s /b Z:\master\*.*') do del %%ithanks Dias, i always get lost in the For commandsThanks for all the input. I have the log I want now. I simple run a batch file that echoes the FIRST batch file's input to a log file. |
|
| 5195. |
Solve : Supress copy output in Batch file? |
|
Answer» Hi, |
|
| 5196. |
Solve : question about setting days to vars? |
|
Answer» Is it possable under xp to give give a user a prompt or window to allow them to select from a list of days. you might want to give them a menu instead yes I have got that but I wish to allow them to select any of the days they wish :example: Mondays Wednesdays and Fridays. I can not get this to work in a batch. I was hopefull that someone has done this in the past or knows of a way to allow user choice for more then one option at a time.why don't you ask for a yes/no answer for each day in turn? Quote from: DIAS de verano on May 20, 2008, 08:08:50 AM why don't you ask for a yes/no answer for each day in turn? This is still not working for me. Here is a section of the code that keeps giving me problems. Code: [Select]:LOOPZB CLS SET Choice= ECHO Do you want JK Defrag to run on Monday? ECHO Enter Yes or No SET /P Choice=Monday: ECHO %choice% |findstr /i /r "[n]" > NUL IF /I %errorlevel% EQU 0 SET mon=no && GOTO LoopZC ECHO %choice% |findstr /i /r "[y]" > NUL IF /I %errorlevel% EQU 0 SET mon=yes && GOTO LoopZC ECHO %choice% is not a valid choice ECHO please try agin ping -n 2 localhost > nul GOTO LoopZB :LoopZC CLS SET Choice= ECHO Do you want JK Defrag to run on Tuesday? ECHO Enter Yes or No SET /P Choice=Tuesday: ECHO %choice% |findstr /i /r "[n]" > NUL IF /I %errorlevel% EQU 0 SET tues=no && GOTO LoopZD ECHO %choice% |findstr /i /r "[y]" > NUL IF /I %errorlevel% EQU 0 SET tues=yes && GOTO LoopZD ECHO %choice% is not a valid choice ECHO please try agin ping -n 2 localhost > nul GOTO LoopZC :LoopZD CLS SET Choice= ECHO Do you want JK Defrag to run on Wednesday? ECHO Enter Yes or No SET /P Choice=Wednesday: ECHO %choice% |findstr /i /r "[n]" > NUL IF /I %errorlevel% EQU 0 SET wed=no && GOTO LoopZE ECHO %choice% |findstr /i /r "[y]" > NUL IF /I %errorlevel% EQU 0 SET Wed=yes && GOTO LoopZE ECHO %choice% is not a valid choice ECHO please try agin ping -n 2 localhost > nul GOTO LoopZD :LoopZE CLS SET Choice= ECHO Do you want JK Defrag to run on Thursday? ECHO Enter Yes or No SET /P Choice=Thursday: ECHO %choice% |findstr /i /r "[n]" > NUL IF /I %errorlevel% EQU 0 SET thurs=no && GOTO LoopZF ECHO %choice% |findstr /i /r "[y]" > NUL IF /I %errorlevel% EQU 0 SET thurs=yes && GOTO LoopZF ECHO %choice% is not a valid choice ECHO please try agin ping -n 2 localhost > nul GOTO LoopZE :LoopZF CLS SET Choice= ECHO Do you want JK Defrag to run on Friday? ECHO Enter Yes or No SET /P Choice=Friday: ECHO %choice% |findstr /i /r "[n]" > NUL IF /I %errorlevel% EQU 0 SET FRI=no && GOTO LoopZG ECHO %choice% |findstr /i /r "[y]" > NUL IF /I %errorlevel% EQU 0 SET fri=yes && GOTO LoopZG ECHO %choice% is not a valid choice ECHO please try agin ping -n 2 localhost > nul GOTO LoopZF :LoopZG ECHO you choose to run on: ECHO you choose to run on: >> "\\%computername%\C$\%homepath%\desktop\defrag.log" IF %mon% == yes ECHO Monday && SET day1=M IF %mon% == yes ECHO Monday >> "\\%computername%\C$\%homepath%\desktop\defrag.log" IF %tues% == yes ECHO Tuesday && SET day2=T IF %tues% == yes ECHO Tuesday >> "\\%computername%\C$\%homepath%\desktop\defrag.log" IF %wed% == yes ECHO Wednesday && SET day3=W IF %wed% == yes ECHO Wednesday >> "\\%computername%\C$\%homepath%\desktop\defrag.log" IF %thurs% == yes ECHO Thursday && SET day4=TH IF %thurs% == yes ECHO Thursday >> "\\%computername%\C$\%homepath%\desktop\defrag.log" IF %fri% == yes ECHO Friday && SET day5=F IF %fri% == yes ECHO Friday >> "\\%computername%\C$\%homepath%\desktop\defrag.log" Pause IF '%day1%' =='' (SET day2=T) ELSE IF NOT '%day2%' =='' SET day2=,T IF '%day1%' =='' && IF '%day2%' =='' (SET day3=W) ELSE IF NOT '%day3%' =='' SET day3=,W IF '%day1%' =='' && IF '%day2%' =='' && IF '%day3%' =='' (SET day4=TH) ELSE IF NOT '%day4%' =='' SET day4=,TH IF '%day1%' =='' && IF '%day2%' =='' && IF '%day3%' =='' && IF '%day4%' =='' (SET day5=F) ELSE IF NOT '%day5%' =='' SET day5=,F set day=%day1%%day2%%day3%%day4%%day5% Pause The batch fails just before the first pause if you do not choose yes to the Monday prompt. thanks again, WayneThat code looks way too complex and ambitious. Get the functioning right first and then add the error trapping. Code: [Select] @echo off :start REM get user input echo. set /p mon="Monday y/n ?" set /p tue="Tuesday y/n ?" set /p wed="Wednesday y/n ? set /p thu="Thursday y/n ?" set /p fri="Friday y/n ?" REM set up string with spaces between letters set string= if "%mon%"=="y" set string=M if "%tue%"=="y" set string=%string% T if "%wed%"=="y" set string=%string% W if "%thu%"=="y" set string=%string% TH if "%fri%"=="y" set string=%string% F REM remove any leading space if "%string:~0,1%"==" " set string=%string:~1,255% REM change each space to a comma and a space set string=%string: =, % echo. echo You chose these days %string% echo. set /p ok="Is this OK y/n ?" if "%ok%"=="n" goto start |
|
| 5197. |
Solve : Newbie help: bat calling .bat file only executes 1st file? |
|
Answer» This should be easy... bat calling .bat file only executes 1st file The problem is you're not calling the batch files but EXECUTING them. There is a subtle difference. When you call a batch file a mechanism is setup to return to the calling file. A called file can in turn call another file, but eventually the run unit will climb the return stack back to the original caller. The way you setup your run unit is to execute another file with no hope of ever returning. As previously mentioned an exit statement in any of the called files will prematurely end the entire run unit. Code: [Select]C: CD\DIR\SUBDIR call 1.BAT REM --- 1 call 2.BAT REM --- 2 call 3.BAT REM --- 3 ... ... call 28.BAT REM --- EOF --- Hope this helps. THANKS FOR THE REPLIES!!! more info: the 1.bat file contents: C:\DATAIN~1/bin/AL_RWJ~1.EXE "C:\DataIntegrator/log/justice_server/" -w "INET:URANUS:3511" -C "C:\DataIntegrator/log/JOB_CMT_Act_Remark.txt" (no exit listed...) I tried adding CALL in front of 1.bat (CALL 1.bat), and that allowed job 2 to start... now it appears hung... (which is possible as the Data Integrator product is close on ram) the REAL gory detials: [JOB_CMT_translate.bat = 1.bat (in my example)] REM *** batch job to execute a bulk load *** REM mrbill 5/29/08 (run) REM job order matters!!! REM ----------------------------------------- C: CD\DataIntegrator\Log rem ----------------- start ---- call JOB_CMT_translate.bat rem ----------------- 1 ---- call JOB_CMT_defendant.bat rem ----------------- 2 ---- call JOB_CMT_Collection.bat rem ----------------- 3 ---- call JOB_CMT_Count.bat rem ----------------- 4 ---- call JOB_CMT_Remarks.bat rem ----------------- 5 ---- call JOB_CMT_Def_Desc.bat rem ----------------- 6 ---- call JOB_CMT_Activity.bat rem ----------------- 7 ---- call JOB_CMT_Act_Remark.bat rem ----------------- 8 ---- call JOB_CMT_Sentence.bat rem ----------------- 9 ---- call JOB_CMT_Bond.bat rem ----------------- 10 ---- call JOB_CMT_Bond_Remark.bat rem ----------------- 11 ---- call JOB_CMT_Sentence_Prov.bat rem ----------------- 12 ---- call JOB_CMT_Witness.bat rem ----------------- 13 ---- call JOB_CMT_Related_Case.bat rem ----------------- 14 ---- call JOB_CMT_Appeal.bat rem ----------------- 15 ---- call JOB_CMT_App_Remark.bat rem ----------------- 16 ---- call JOB_CMT_Arrest.bat rem ----------------- 17 ---- call JOB_CMT_Attorney.bat rem ----------------- 18 ---- call JOB_CMT_Sc_Event.bat rem ----------------- 19 ---- call JOB_CMT_Add_Sch_Cnts.bat rem ----------------- 20 ---- call JOB_CMT_Remark_Note.bat rem ----------------- 21 ---- call JOB_CMT_Add_Remark.bat rem ----------------- 22 ---- call JOB_CMT_Def_Note.bat rem ----------------- 23 ---- call JOB_CMT_Evidence.bat rem ----------------- 24 ---- call JOB_CMT_Alias.bat rem ----------------- 25 ---- call JOB_CMT_Custody.bat rem ----------------- 26 ---- call JOB_CMT_Sheriff_Note.bat rem ----------------- 27 ---- call JOB_CMT_Warrant.bat rem ----------------- 28 ---- REM ))))))))) all done ))))))))))))))))) rem *********************** end of job ******* Quote I tried adding CALL in front of 1.bat (CALL 1.bat), and that allowed job 2 to start... The calls are appropriate. The sequence of events so far would be, control.bat starts which in turn calls 1.bat which executes C:\DATAIN~1/bin/AL_RWJ~1.EXE. When the latter is finished, control reverts back to 1.bat which has no more instructions, so control reverts back up the chain to control.bat which then calls 2.bat. The numbered (1.bat, 2.bat, etc) batch files do not terminate until the exe file being executed is ended. My guess is that the DataIntegrator program is the source of the hangup. Batch files are containers for instructions you can duplicate at the command prompt. Try entering the control.bat commands MANUALLY at the prompt and see how things go. Liberal use of echo on is recommended until you get the run unit working. Any reason you need all these batch files? Could you run the RJW programs directly from control.bat? Hope this helps. |
|
| 5198. |
Solve : Using if else in batch scripting? |
|
Answer» How to check 3 conditions from batch scripting Did you leave out an echo? Yup Exclusive OR Venn diagram: the red part is true XOR is one or the other but not both. A XOR B = (NOT (A=B) and (A OR B))Quote Care should be taken when converting an English sentence into a formal Boolean statement. Many English sentences have imprecise meanings, e.g. "All that glisters is not gold,"[1] which could mean that "NOTHING that glisters is gold" or "some things which glister are not gold". http://en.wikipedia.org/wiki/Boolean_logic "I always carry an umbrella for when it rains and snows." this is valid because there is an implication: "I always carry an umbrella for when it rains and for when it snows."Quote from: BC_Programmer on September 16, 2009, 08:52:43 PM "I always carry an umbrella for when it rains and snows."OK, Maybe we can close this thread if you will just write a batch file using the IF...ELSE structure to demonstrate the above logic. Thanks Salmon Trout ----- IF "%animal%"=="dog" set /a bool=%bool%+1 IF "%colour%"=="red" set /a bool=%bool%+1 if %bool% EQU 2 ( echo condition 1 AND condition 2 are both true ) ELSE ( echo condition 1 AND condition 2 are NOT both true ) --------- This thing is really working great, now i can allow any no. of conditions in a IF loop. initially i thought like "C" language i can enter elseif condition. Thanks again. |
|
| 5199. |
Solve : Help with batch file- read Nth line in delimited text file? |
|
Answer» Ghost Dog wrote: I have to write a batch file in DOS for work vbscript is probably disabled... Quote from: billrich on September 13, 2009, 01:35:01 AM Gosh, GhostDog is really smart.that sounds sarcastic...but nevertheless...thank you for your compliment. Quote Now GhostDog will demostrate that the *.vbs script fits the defintion of a Batch File.its already done. like that i posted. Quote But please, GhostDog, post your test data and that your *.vbs( VBScript ) script actually works. [/font] since you are so insistent Code: [Select]C:\test>more file 1,0,mess,nothing 2,0,mess,nothing 3,0,mess,nothing 4,0,mess,nothing 5,1,mess,nothing C:\test>cscript /nologo test.vbs 1,0,mess,nothing 2,0,mess,nothing 3,new value,mess,nothing 4,0,mess,nothing 5,1,mess,nothing C:\test>more test.vbs Set objFS=CreateObject("Scripting.FileSystemObject") strFile = "c:\test\file" Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfLine linenumber = objFile.Line strLine = objFile.ReadLine If linenumber = 3 Then csv = Split(strLine,",") csv(1) = "new value" strLine = Join(csv,",") End If WScript.Echo strLine Loop objFile.Close 2nd field, line 3 is changed to "new value". does that answer your query?Quote GhostDog wrote: No, the second field is a flag field and must be either 1 or 0. "new value" is the WRONG answer. Your code does not work. You also did not assign the the first field to a variable. Why post code that has not been tested? The OP requested real "Batch code" not incorrect VBScript.Quote from: billrich on September 13, 2009, 10:46:40 AM Your code does not work.yes it does work. Except that I did not provide OP with FULL code. Implementing that flagging system is fairly easy. I want OP to try himself. Code: [Select]if csv(1) = 0 Then csv(1) = 1 end if in fact, there is really no need to do the above, because by changing "new value" in my code to "1", it will still do the same thing... Quote from: billrich You also did not assign the the first field to a variable.if OP has the motivation to learn vbscript, he should be able to do that himself. Quote Why post code that has not been tested?its tested .... you just don't see the point i am making... Quote The OP requested real "Batch code" not incorrect VBScript.once again, define what is real Batch code, accurately. Dude, if you are GOING to provide him your solutions in full , go ahead. Depending on my MOOD, I am not obliged to solve everything for OP. If i really want to nitpick about your code, i would do that, but i will not. for example, Input argument checking, input file format ambiguity, eg your code checks for ",0," .... what if the input data is " , 0 ," therefore, would you just give it a rest... |
|
| 5200. |
Solve : Help Creating a Batch File to Set Clock Back 5 minutes? |
|
Answer» Quote from: PATIO on September 13, 2009, 07:38:30 PM That's NOT what Salmon was saying...re-read the Post.I STAND CORRECTED. He did not say what I thought he SAID. |
|