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.
| 4601. |
Solve : Batch - append text to output of another command? |
|
Answer» HELLO, I am using this; Code: [Select]:: List all the .doc files in a directory DIR /b /o "c:\some_directory\*.doc">>filenames.txt Which generates a nice list LIKE this; file1.doc another file.doc third file.doc This is lovely and has made me happy, but the simple question is how do I append a 'tab' character and some text to this nice list to give me the FOLLOWING output in my filenames.txt file; file1.doc tab text_in_here another file.doc tab text_in_here third file.doc tab text_in_here Its driving me mad!! Many thanks for any help, Cheers, Stageyou can use for loop together with your dir command. as an alternative solution, you can use this vbscript Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "c:\some_directory" Set objFolder = objFS.GetFolder(strFolder) For Each strFile In objFolder.Files If objFS.GetExtensionName(strFile) ="doc" Then WScript.Echo strFile.Name & vbTab & "some words" End If Next save as myscript.vbs and on command line Code: [Select]C:\test> cscript /nologo myscript.vbs > newfile Quote from: stage on May 10, 2009, 03:52:34 AM Hello,As gh0st said, you COULD use a for loop, as demonstrated here: Code: [Select]for /f "delims= " %%A in ('DIR /b /o c:\some_directory\*.doc') do echo %%A text_here>>filenames.txt That should work as LONG as the filenames or the path don't contain spaces.Hey there, Perfect. Thanks so much. I've learnt alot just in this one exercise. Helpmeh answer does work ok with spaces in filenames but not spaces in directories. This is not a problem. Cheers, StageQuote from: stage on May 10, 2009, 12:53:35 PM Hey there,Ok, I wasn't sure if it would work properly with spaces. I did it all free-thought (without debugging at all). |
|
| 4602. |
Solve : defrag? |
|
Answer» how do i make a batch file that will open defrag, start it, and shutdown after it Quote try contacting customer support. The above is your response to a general question in another THREAD. Now that you've asked your general question here, I wonder if you have tried to write any of the code yourself? Quote from: computerperson#1 on May 21, 2009, 03:18:13 PM how do i make a batch file that will open defrag, start it, and shutdown after it You open a text editor, type the lines of code, then save the file. what are the lines of code Why to people think Command Prompt can do all these magical things?Quote from: computerperson#1 on May 22, 2009, 05:29:32 AM what are the lines of code You need to "learn" how to write them. That is your task. I cant say the only reason why I attempt to do it is so that I can make things easier. IE if I am working on another machine and want a sepfic series of things to happen and dont want to sit in that room and work on whatever else.Okay...... Anyways, if you're looking for a way to start programs automatically at different times, I suggest a program called Kana Reminder. http://www.snapfiles.com/reviews/Kana_Reminder/kanareminder.html Learn it like I had too, call ms paint and go from there and ask questions after learning dos.Quote from: squall_01 on May 22, 2009, 03:52:43 PM Learn it like I had too, call ms paint and go from there and ask questions after learning dos. Junis, is that you? so defrag. just defrag? ok Code: [SELECT]L:\>defrag /? Usage: defrag <volume> [-a] [-f] [-v] [-?] volume drive letter or mount point (d: or d:\vol\mountpoint) -a Analyze only -f Force DEFRAGMENTATION even if free space is low -v Verbose output -? Display this help text shutdown: Code: [Select]L:\>shutdown /? Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy] No args Display this message (same as -?) -i Display GUI interface, must be the first OPTION -l Log off (cannot be used with -m option) -s Shutdown the computer -r Shutdown and restart the computer -a ABORT a system shutdown -m \\computername Remote computer to shutdown/restart/abort -t xx Set timeout for shutdown to xx seconds -c "comment" Shutdown comment (maximum of 127 characters) -f Forces running applications to close without warning -d [u][p]:xx:yy The reason code for the shutdown u is the user code p is a planned shutdown code xx is the major reason code (positive integer less than 256) yy is the minor reason code (positive integer less than 65536) Finished Product: Code: [Select]Defrag %homedrive% shutdown -s -f -t 00 |
|
| 4603. |
Solve : get command within ftp? |
|
Answer» Hi, Hi,Are you sure the pictures are formatted correctly?Yes. Am getting a 550 error in MS-DOS. Not sure what that is TELLING me though.Quote from: MOC76 on May 09, 2009, 05:31:28 PM Yes. Am getting a 550 error in MS-DOS. Not sure what that is telling me though.Does it specifically say error? Because when I used ftp, it would look something LIKE this: 000>Text 909>Different Text and so on and so fourth...when you want to get file TYPES like jpg, set the transfer to binary formatSo before transfering, add "binary" before get.Thanks. I have tried that but no joy. I enter the get command for a .jpg file and receive the following back (see the attached). File is sent to my local directory but is empty (0 KB). I have read that this "550 No such file or directory" message is to do with permissions. However I can't find anything which explains what is required to rectify this. Appreciate any help. [attachment deleted by admin]Quote from: MOC76 on May 10, 2009, 06:05:46 AM Thanks. I have tried that but no joy.In your FTP Browser, right click on the images, and check that they are not hidden, read only or archived. |
|
| 4604. |
Solve : how to terminal the auto loop of bat? |
|
Answer» i make a BATCH FILE, this is ENTIRE code: i make a batch file, this is entire code:It shouldn't auto-rerun, but just to be sure, add EXIT to the very end of it. |
|
| 4605. |
Solve : Create hidden folder?? |
|
Answer» I know how to create a normal folder. What I need to do is create a folder from a batch file that is already hidden so I do not need to go in and manually MAKE the folder hidden. Thank you Evan. works fine.So...ban (which I will probably implement after putting your name in again...) will work like this: Code: [Select]if /i "%msg%"=="/ban" ( echo Ban who? set /p ban=Username^: echo. > "Hiddenpath\%ban%" attrib +h "Hiddenpath\%ban%" echo %ban% has been banned. > %serv% goto modview That will ban someone...then this will check to see if they are banned whenever they send a message. Code: [Select]if exist "Hiddenpath\%usr" ( :loopban cls echo You have been banned. The ban will be reviewed by the admin. pause > nul goto loopban It will go between :msgloop and set /p msg=Message^: in chatter...and won't go after :modview, so the mods can't get banned...good idea!My checker just goes when they try to log in to any COMPONENT of the program.Quote from: Xenfire on May 09, 2009, 04:10:09 PM My checker just goes when they try to log in to any component of the program.What do you mean it just goes away? It just EXITS? Did you do that on purpose? (if the second question was yes)I didn't say "goes away" I just said "goes" as in runs. double check the contents of the post before you reply silly.Quote from: Xenfire on May 10, 2009, 08:09:27 AM I didn't say "goes away" I just said "goes"Well it obviously runs when they first run the program, although then you'd have to PUT it in more than once. |
|
| 4606. |
Solve : Shortcut Variables? |
|
Answer» I don't know what they're called, so I'm calling them shortcut variables. I'm wondering about the variables such as %computername%, what all variables are there? I can't find anything about them.They're Environment Variables. Oh, Environment Tables. Thank you. Environment variables. Type SET at the COMMAND prompt to see what they all are on your computer.List: %CD% - CURRENT Directory %DATE%, %TIME%, %NUMBER_OF_PROCESSORS% - Self Explanatory %OS% - Doesn't exactly tell you the OS, just the family(Like WIN2K, XP are shown as Windows_NT in this variable) |
|
| 4607. |
Solve : is this bat right? |
|
Answer» when i open it and press "y" it says y was unexpted at this time what is wrong. |
|
| 4608. |
Solve : User Input Time Limit? |
Answer» QUOTE from: macdad- on May 10, 2009, 03:02:53 PMWhat SERVICE pack do you have?SP2...I can't get SP3Interesting...wonder why they cut out CHOICE in SP3.... Oh well.Quote from: macdad- on May 10, 2009, 03:14:18 PM Interesting...wonder why they cut out Choice in SP3....It's not in SP2. |
|
| 4609. |
Solve : Simple way to extract text from a group of files?? |
|
Answer» Hello all! |
|
| 4610. |
Solve : DOS Sleep.com command. Where is it?? |
|
Answer» DOS Sleep.com command. Where is it? I thought there was a more or less standard Sleep.com program for DOS. I guess not. For what it is worth, here is a sleep command from my old 1098 collections of stuff I did in ASM. http://geek9pm.com/asm/ No Mallware, no virus. Just plain old 16 bit DOS programs. The only on of INTEREST in SLEEP.COM and SLEEP.ASM. SORRY, can not recall how it works. That was years ago. |
|
| 4611. |
Solve : Command won't work from notepad .bat file? |
|
Answer» Hello, first post. When I run mybat.bat file the window comes up for a fraction of a second and disappears. This suggests to me that you are running it from Windows Explorer by double clicking. When trouble shooting a batch file that behaves in this way, a good idea is to run it by OPENING a command prompt, changing the current drive and directory as appropriate, and finally typing the batch file name at the prompt. That way if the batch crashes out you just get the prompt back and you can see any error messages. These may give you (and us) an idea of what is happening. In this case, it won't be necessary, as the problem is obvious. Where you use one percent sign in a FOR variable at the prompt, you use TWO of them in a batch file. Thus %i and %j NEED to become %%i and %%j. Quote I've been struggling with this for quite some time. As with most commands, help is available by typing the command at the prompt with the /? switch. Code: [Select]C:\>for /? Runs a specified command for each file in a set of files. FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files. Wildcards may be used. command Specifies the command to carry out for each file. command-parameters Specifies parameters or switches for the specified command. To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I. (That is just the beginning of the very detailed FOR help, which runs to about 4 screens) Perhaps you should get used to using the prompt more. Thank you so MUCH. This fixed the problem. I was beating myself up over this error. Is there anywhere you could point me towards to read up on the little intricacies like this so I can avoid the ANGUISH and having to post a seemingly obvious problem here? Thanks again!Quote from: jinky1087 on May 22, 2009, 11:46:24 PM Is there anywhere you could point me towards to read up on the little intricacies like this Quote from: Me, above As with most commands, help is available by typing the command at the prompt with the /? switch. Or there are plenty of command prompt help sites you can find by using Google. This is one I have bookmarked http://www.ss64.com/nt/ Here's a tip. If you use the CD command with the /D switch, you can change drive and directory at the same time. That is Code: [Select]D: cd Video May be replaced with Code: [Select]cd /d D:\Video |
|
| 4612. |
Solve : Batch file to disconnect 3g wireless modem and reconnect? |
|
Answer» HI all this is sort of related to my other post. Does anyone KNOW how to write a batch file that will disconnect a 3G WIRELESS modem and reconnect it. And wether this can be done in one batch file or requires TWO batch files. This will be run via a scheduled task. Any help would be awesome Cheers Jason |
|
| 4613. |
Solve : msxml5.dll? |
|
Answer» Hi guys, |
|
| 4614. |
Solve : call other bat? |
|
Answer» how do you call a BATCH FILE. when i find the properties it does not show the target. Please explain more fully what you want to do. what i mean is that when i create a batch file and i want to call another batch file. when i right click on it on the desktop it does not have a target to call.call BATCHFILENAME.BATthanks Quote from: computerperson#1 on May 22, 2009, 07:27:17 PM thanksWas it THAT difficult that you couldn't do it yourself? Type HELP COMMANDNAME at the command prompt for INFORMATION on the commands, and how to use them. |
|
| 4615. |
Solve : Delete certain lines of text file?? |
Answer» ESPECIALLY at school, where the OPTION to VIEW hidden FILES is restricted for most COMPUTERS. Except for yours and Zack'sQuote from: Xenfire on May 09, 2009, 04:11:03 PMespecially at school, where the option to view hidden files is restricted for most computers. Except for yours and Zack'sYeah...sure... |
|
| 4616. |
Solve : Exit the ms-dos window after finish a bat file? |
|
Answer» Doesn't work?I don't really know if I am doing well. I don't really know if I am doing well.What do you mean?How can I tell you about my configuration or actual situation ? If works in other parts I SUPPOSE have to revise my configuration. Quote from: Esgrimidor on May 09, 2009, 11:28:19 AM How can I tell you about my configuration or actual situation ?Try putting a pause after each line, then you can tell what is causing problems.don't work the vb script. The bat goes well. At the present MOMENT I have problems with my autocad 2002. When I enter in macro options herr- macro I'm trying reinstall office xp and reinstall vb6 runtimes sp6 with no good results. That may be the CAUSE I don't get good result |
|
| 4617. |
Solve : using MSMTP from the command line? |
|
Answer» I need to send an email from the command line/batch script. I am currently using MSMTP for this. I'd be willing to change BUT the program MUST be able to send using a Gmail account. i cannot found a way to attach additional files when using msmtp. Can be done by encoding with base64 i finally found a better way to send mail at command line ehco 'mail CONTENT' | mutt -s 'subject' -a additionalFileName [emailprotected] FWIW, I've used blat for years to send mail from a script. It works great Development seems to have slowed, but it is very mature http://www.blat.net/ \\uSlackr |
|
| 4618. |
Solve : .bat that formats d drive? |
|
Answer» because I want to know how to do that kind of bat file. Does it really need a specific reason?? I have also tried to do bat file that opens different programs at the same time... And it partially worked... because I want to know how to do that kind of bat file. Does it really need a specific reason?? Yes. We are a responsible forum. A script that could format without user intervention is potentially DISASTROUS and very few people need to do it. Such a script could be used for malicious purposes, by stupid prank playing idiots, and it is not really all that hard for you to work it out for yourself. Feel free to experiment on your own hardware. aa now I got it hehe I didn't even think about that... well I don't even know how to disguise bat file so that someone would actually run it I just wanted to CREATE something effective with bat file... Creating a bat file that opens programs sounds so booring :d but I see that I have to settle with that then... So could you help me to finish that another bat that opens different programs... ? Quote C:\Windows\notepad (this actually works fine) Quote but those last two didn't open You need to enclose a path + filename in quote marks if it contains contains ONE or more spacesokey. thank you, got it right now You want me to toss you in and tell you to swim?Quote from: squall_01 on May 22, 2009, 03:57:07 PM You want me to toss you in and tell you to swim? ehm.. watyou have to learn the basic for before you move to the advanced.Quote from: Dias de verano on May 22, 2009, 03:46:30 AM You're new here, aren't you? well. yes...besides the point. Carbon said: Quote from: Carbon Dudeoxide on May 21, 2009, 11:22:25 PM What's wrong with Right Click --> Format? which is basicly easier. i know. but he wants to know what is wrong with his script because he COULD just right click and format. i didn't mean to sound obvious. im just telling carbon that he wants to find the problem instead of just getting over it Quote Insert Quote Quote from: BatchFileBasics on May 22, 2009, 04:47:56 PM well. yes...besides the point. “You must be new here.” is a "Slashdot meme", in other words, the height of wit and humour. In Soviet Russia, the batch file writes you! Incidentally, does this REMIND people of anyone? Quote 'Junis' referencing the infamous story in which an Afghani named 'Junis' purportedly was BACK online via his Commodore computer. Used to describe doubt of authenticity of a posted claim, such as 'Junis, is that you?" |
|
| 4619. |
Solve : Starting an application minimised? |
|
Answer» Hi All, I'm new here. I'm after some help with my first post. |
|
| 4620. |
Solve : MS-DOS rename? |
|
Answer» I'm trying to rename many similar file names at once. @echo off & setlocal enabledelayedexpansion In trying to understand the code this is my understanding: @echo off & setlocal enabledelayedexpansion COMMANDS NOT DISPLAYED TO SCREEN & PERFORM COMMANDS LOCALLY (CURRENT DIRECTORY ONLY?) for %%a in ("CND_m2_*.SHT") do ( ==FOR %variable IN (set) DO command [command-parameters]== FINDS WHERE THE FILENAME = “CND_m2_*.SHT” (NAMED VARIABLE A) set f=%%~na set f=!f:CND_m2_=! CREATES SET OF FILES TO PERFORM COMMAND TO (SET NAMED “CND_m2_*.SHT”) ren "%%~nxa" "!f!.DGN" RENAME ) What am I missing or doing wrong? Thankshere's a vbscript alternative Code: [Select] Set objFS = CREATEOBJECT("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) For Each strFile In objFolder.Files strFileName = strFile.Name If InStr(strFileName,"CND_m2") > 0 Then strFileName = Replace(strFileName,"CND_m2_","") strFileName = Replace(strFileName,"_WORKING.SHT","") strNewName = strFileName & ".DGN" strFile.Name= strNewName End If Next save as myscript.vbs and on command prompt, Code: [Select]c:\test> cscritp /nologo myscript.vbs 1. put the batch file inside the same folder as .SHT files 2. start-->run-->type cmd then enter 3. cd to the directory where the .SHT files eg. cd c:\test\ 4. type batchfile.bat at cmd prompt or rename the batch file to cmd extension and double-click to runQuote I tried this as a batch (stored in the same folder as the files) and the cmd window flashed on & off but nothing happened. I opened a cmd window and pasted and got this:I clicked the bat which makes sense now why pops up run and closes a command window, but when I pasted the command after changing directory (cd) to the folder containing the files i want to change, is when i got the errorThanks gh0std0g74 Yes! That removed the beginning part, but only added .dgn to the end. In the cmd window Quote ren *_working.sht.dgn *.dgndoesn't make any changes either. But, Quote ren ??_working.sht.dgn ??.dgnchanges the filename correctly. Is there a way to WRITE the script character specific (quantity wise)?Quote from: fsjeep on May 13, 2009, 07:42:01 PM I'm trying to rename many similar file names at once.Code: [Select]@echo off & setlocal enabledelayedexpansion pushd c:\workingshitfolder\ && ( for %%a in ("CND_m2_*.SHT") do ( set f=%%~na set f=!f:CND_m2_=! set f=!f:_WORKING=! set f=!f:~,6!!f:~7,1!!f:~6,1!!f:~8,99! echo "%%~nxa" --^> "!f!.DGN" ren "%%~nxa" "!f!.DGN" ) popd ) || echo invalid folder pause example output: Code: [Select]D:\batch>dir/b cnd* CND_m2_CND-7130-01_WORKING.SHT D:\batch>sht "CND_m2_CND-7130-01_WORKING.SHT" --> "CND-7103-01.DGN" Press any key to continue . . . D:\batch>dir/b cnd* CND-7103-01.DGNThanks Reno! that last one works awesome!! |
|
| 4621. |
Solve : Watch Folder - Need Batch file? |
|
Answer» Hi All, Hi All,So... @echo off :loop if exist FILENAME goto cont ping localhost -N 10 -w 1000 > nul goto loop :cont move FILENAME BACKUPFOLDER rest of commands hereQuote from: mrgreekgod on May 11, 2009, 12:26:26 PM I need a batch file which watches the folder for a particular file[i have 30 to 40 files,any one of them can be placed] for every 10 secs,if found move the file to backup folder,delete the same and trigger the vbs file to do some action. you can do the whole thing in vbscript: Code: [Select]watch="." dest=".\backup\" set d=createobject("scripting.dictionary") with createobject("scripting.filesystemobject") if not .folderexists(dest) then .createfolder dest do wsh.echo "tick count, checking.." for each f in .getfolder(watch).files if not d.exists(f.name) then wsh.echo "adding to watch list:",f.name d.add f.name, f.datelastmodified elseif f.datelastmodified<>d.item(f.name) then wsh.echo f.name,"was modified, move to",dest,"folder" f.move dest end if next wsh.sleep 10000 loop end with Quote from: mrgreekgod on May 11, 2009, 12:26:26 PM [i have 30 to 40 files,any one of them can be placed] for every 10 secs,not sure about "any one of them can be placed", but the above code will watch current folder for modified file, if modified move the file to backup folder.Quote from: Helpmeh on May 11, 2009, 02:39:18 PM So... If you want the script to sleep for 10 secs, you may need 11 requests in the "ping" COMMAND. Because, in the ICMP protocal, the first response takes no time nearly. Code: [Select]ping localhost -n 11 -w 1000 > nulQuote from: Batcher on May 11, 2009, 11:53:14 PM If you want the script to sleep for 10 secs, you may need 11 requests in the "ping" command. Because, in the ICMP protocal, the first response takes no time nearly.the -w 1000 will make it wait 1000 miliseconds for each ping, so -n 10 -w 1000 WOULD be 10 seconds. -n 11 would be 11 seconds. |
|
| 4622. |
Solve : How to Run Mulitple .bat file in sequence after one is finished.? |
|
Answer» I have four .bat file which I made for a task but now I want to put those batch files in a ANOTHER batch file which will run them one by one in the sequence, that is when first batch files is FINISHED second should start automatically and then third and so on. call 1.bat |
|
| 4623. |
Solve : Can i make a batch file that will make a shortcut to something on the desktop?? |
|
Answer» it WORKS here too. |
|
| 4624. |
Solve : Another copy question.? |
|
Answer» I have asked for a way to copy all the files from a USB to my computer in a previous topic, but is it POSSIBLE to copy all files with a CERTAIN extension? I have asked for a way to copy all the files from a USB to my computer in a previous topic, but is it possible to copy all files with a certain extension?copy *.EXT copytoAh now I see why it didn't work, I forgot the dot. Thanks a LOT! Quote from: Fairadir on May 22, 2009, 04:09:17 PM Ah now I see why it didn't work, I forgot the dot.Lol... |
|
| 4625. |
Solve : Batch file stops running if it launches an exe file? |
|
Answer» Hello! |
|
| 4626. |
Solve : HELP ME PLEASE!!!...IF command? |
|
Answer» I don`t know what`s wrong... I don`t know what`s wrong... well lets look at: Code: [Select]IF EXIST file.ext GOTO yes IF NOT EXIST file.ext GOTO no :yes ... Exit :no ... Exit You don't need Code: [Select]IF NOT EXIST file.ext GOTO no since THERES no other option so your looking at Code: [Select]IF EXIST file.ext GOTO yes goto no so if it exists, goto yes, if it doesn't it will continue the script and goto no ALSO. you might want to add in the directory of the fileI try it but the IF command don`t work with GOTOare you sure your doing it like this? Code: [Select]if exist c:\windows\myfile.txt goto yes goto no well try this code out, except replace myfile.txt with the name of your file Code: [Select]@echo off if exist c:\windows\myfile.txt goto yes goto no :yes echo Worked pause exit :no echo didn't work pause exit The original .bat be... ----------------------------------------------- IF EXIST autorun.inf GOTO yes goto no :yes ren .... DEL... exit :no echo... set /p... ...etc... exit --------------------------------------------------- but the shell show me something like this "The command`s syntax is incorrect"thats interesting. well lets see the full error: open up command prompt type the full path and name of your batch c:\path of file\file.bat and press enter. and it should say the error then resume to command promptI don`t understand why appear the message "The syntax of the command is incorrect"...I follow you step to step....fu___ batch well there goes my ideas. the if syntax shouldn't have any problems with exist. so if anyone else wants to try and help. please(1) If the file is not in the same FOLDER as the batch file you need to use the full path. (2) If the file name and/or path has one or more spaces you need quote marks before and after it. They do not do any harm if there are no spaces. (3) Contents of folder: Code: [Select]S:\Test\Batch\ifexist>dir Volume in drive S is USBHD Volume SERIAL Number is 2C51-AA7F Directory of S:\Test\Batch\ifexist 22/05/2009 07:40 <DIR> .. 22/05/2009 07:40 <DIR> . 22/05/2009 07:40 7 test.txt 22/05/2009 07:43 137 test.bat 2 File(s) 144 bytes (4) test.bat: Code: [Select]@echo off if exist "test.txt" (goto yes) else (goto no) :yes echo file exists goto end :no echo file does not exist :end pause (5) Output on screen: Code: [Select]S:\Test\Batch\ifexist>test.bat file exists Press any key to continue . . . (6) I edited test.bat: I changed if exist test.txt to if exist test1.txt (which does not exist)... Code: [Select]S:\Test\Batch\ifexist>test.bat file does not exist Press any key to continue . . . Can the OP show which command line is causing the error or is it just assumed that it's the If exist command line?OK tanks everybody...but, for example I have in a directory named "Test" the next files: autorun .inf, autorunH.inf and the batch. The batch cotains the next commands: ----------------------------------------------------------------------------------- @echo off IF exist "Autorun.inf" (GOTO yes) ELSE (GOTO no) :yes ren %USERPROFILE%\desktop\test\Autorun.inf Autorun1.inf ren %USERPROFILE%\desktop\test\AutorunH.inf Autorun.inf pause Exit :no ren %USERPROFILE%\desktop\test\AutorunH.inf Autorun.inf pause Exit ------------------------------------------------------------------------------------ but the batch file doesn`t works cause appear the same message ervery time "The syntax of the command is incorrect"... What is it OP?1. You didn't take any notice of what I wrote about paths and filenames with spaces in them. 2. The OP is you. Original Poster. |
|
| 4627. |
Solve : Dos script to back up data, CD Rom? |
|
Answer» HI, Can anyone help me with the script to backup the datas to CD Rom, in a BAT file i tried Xcopy but its not working , thanks in advance AxlCD-ROM (Compact Disc, read-only-memory) so COPY would not work. which is where cd burners come in. ASSUMING your computer has a built in cd burner. lets go ahead and find a cd burner program that has a command line... well heres Commandburner: Code: [Select]http://www.snapfiles.com/download/dlcommandburner.html simply install-setup heres the command lines: Code: [Select]Usage: [b]CmdBurn command <OPTIONS>[/b] Where command is one of: burn eject erase fullerase and <options> is one or more of: /[b]f filepath /d dirpath /l label /erase /eject /fullerase /noexit /?[/b] [b]filepath is the name of the file you wish to burn dirpath is the directory you wish to burn[/b] label is the label of the CD / DVD /erase if you want to erase before burn [b]/eject if you want to eject after burn[/b] /fullerase if you want to a full erase before burn (you don't need to also say /erase) /noexit if you want to return to interactive mode when the batch process is completed [i][b]/hide if you want hide the user interface during operation[/b][/i] /prompterase (use with burn command) if you want to prompt the user when erasing a disc that already contains data - do not use with /hide /popuperror (use with burn command) if you wish to display a popup if an error occurs - do not use with /hide /? if you want to see this usage information try something along the lines of: Code: [Select]"C:\Program Files\CommandBurner\CmdBurn.exe" /f c:\file.txt [b]OR[/b] /f c:\files\ /label "SHORT cd label" /eject along those lines |
|
| 4628. |
Solve : Having trouble with multiple steps within a FOR loop? |
|
Answer» Here's the sit: |
|
| 4629. |
Solve : creation of error logs? |
|
Answer» I want to copy a folder with FILES and sub-directories into a different folder in a network. I want to GENERATE a log for the folders/files which were not copied. |
|
| 4630. |
Solve : Write .bat to startup folder? |
|
Answer» Hi there i'm new so hello! |
|
| 4631. |
Solve : How to spawn a program from batch file?? |
|
Answer» I want to call executable program from batch file, but RETURN IMMEDIATELY from program just started and not wait for the executable to end. |
|
| 4632. |
Solve : Listing files created or modified on a certain date? |
|
Answer» In the old MS-DOS there was a way to LIST ONLY the files created in a certain time window for instance 2009-05-11 to 2009-05-12 using the /D switch. For instance: you need /O switch: which version has that /d=MM-DD-YYYY switch? Because I've never seen it and I started with MS-DOS 3.30. I believe aanvd may be misremembering. i was reading dir /? to fast and didnt chcek it, sry for that, and i think for loop will be good hereuse vbscript Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "C:\test" Set objFolder = objFS.GetFolder(strFolder) For Each strFile In objFolder.Files strDate = FormatDateTime(strFile.DateCreated,vbShortDate) If strDate = "5/12/2009" Or strDate = "5/13/2009" Then WScript.Echo strFile.Name End If Next save as myscript.vbs and on command prompt Code: [Select]c:\test> cscript /nologo myscript.vbs if you want to do in batch, use the for loop with delim and tokens set , go over dir /tc, get the creation date, compare with what date you want and echo out the result.something similar to /d switch is the xcopy Quote /D:m-d-y Copies files changed on or after the specified date. the code: Code: [Select]C:\>md fakedir C:\>echo.nnnnnnnnnnnnnn|xcopy *.txt fakedir /d:05-1-09/p C:filename.txt (Y/N)? n C:index.txt (Y/N)? n C:n10.txt (Y/N)? n C:newfile.txt (Y/N)? n C:order.txt (Y/N)? n C:save.txt (Y/N)? n C:seven 7.TXT (Y/N)? n C:sevench.txt (Y/N)? n C:test.txt (Y/N)? n 0 File(s) copiedxxcopy is free for personal use, has syntax which is a superset of xcopy, has a "list files which would be copied" mode (LIKE xcopy), and crucially considering the original question, can be instructed to work with a date range. (UNLIKE xcopy). |
|
| 4633. |
Solve : Batch file won't stop executing old code? |
|
Answer» I have a simple batch FILE I want to execute. Please rename BATCH 1 to test.batThat was it! Thanks! |
|
| 4634. |
Solve : CPU time? |
|
Answer» Is there a WAY to have windows allocate more CPU time to a command prompt (cmd.exe)? I don't mean priority but CPU % time. |
|
| 4635. |
Solve : Batch File ~ Help Please? |
|
Answer» Halo All , Halo All ,Most people don't know about the pause/break thing, but if you add Code: [Select]ping localhost -n (Time in seconds) -w 1000 > nul somewhere in the loop, it should serve your purposes. If you don't want them to close it, then you can use the .exe I made just now to do it (it runs in "ghost mode"). [attachment deleted by admin]Or the Sleep command, if you have XP. Parameters: Code: [Select]Sleep [Seconds to Wait] But if you want it in a more precise time, like in milliseconds then use Ping that Helpmeh advised. Hope this helps ,Nick(macdad-)Quote from: macdad- on May 10, 2009, 03:08:26 PM Or the Sleep command, if you have XP.You need to download it first...even if you have XP.Quote from: macdad- But if you want it in a more precise time, like in milliseconds then use Ping The sleep.exe I use (server 2003 resource kit) has a -m switch that specifies time in milliseconds sleep -m 250 waits a quarter of a second. Code: [Select]On Error Resume Next comp=array(".") q="select * from __InstanceCreationEvent within 1 where " & _ "targetinstance isa 'win32_process' and "& _ "(targetinstance.name='sndvol32.exe' or targetinstance.name='rundll32.exe')" for each c in comp set a=getobject("winmgmts:\\" & c).execnotificationquery(q) do a.nextevent.targetinstance.terminate createobject("wscript.shell").run "d:\setvol.exe 10" loop next vbscript alternative to prevent sndvol32.exe to run, save the above as prevent.vbs Code: [Select]wscript prevent.vbs to manage whole LAN, you can add each client computers name to the array and run the vbs from eg.cashier computer. above code only tested on local computer.Thank you guys all soo much for the help & ADVICE for now I'm just using a simple batch file converted to exe with ping for the delay. Sleep & the vbscript idea definitely sounds PROMISING will give it a try and let you all know the outcome. Thanks once again |
|
| 4636. |
Solve : read a record of a data file in batch file? |
|
Answer» can some one tell me how to open a data file (text file), then read the record one at a time in MS-DOS batch file. create a letter What? for /f "delims=1" %%A in ('type name.txt') do ( set /a num+=1 set %num%=%%A if %num%==1 echo A if %num%==2 echo B if %num%==3 echo C if %num%==4 echo D if %num%==5 echo E if %num%==6 echo F if %num%==7 echo G if %num%==8 echo H if %num%==9 echo I if %num%==10 echo J if %num%==11 echo K if %num%==12 echo L if %num%==13 echo M if %num%==14 echo N if %num%==15 echo O if %num%==16 echo P if %num%==17 echo Q if %num%==18 echo R if %num%==19 echo S if %num%==20 echo T if %num%==21 echo U if %num%==22 echo V if %num%==23 echo W if %num%==24 echo X if %num%==25 echo Y if %num%==26 echo Z ) set num2=0 :loop set /a num2+=1 echo %num% if %num%==%num2% goto pause goto loop :pause pause > nul That will display the entire contents of the file (and up to 26 letters, depending on the AMOUNT of names). But you can do whatever you want witht the names.Hi Helpmeh, You need enable delayed expansion in your code.believe or not, you just saved me 10 hrs per week at my work by using a batch file. many thanks. Quote from: dwowang on May 13, 2009, 05:43:21 PM believe or not, you just saved me 10 hrs per week at my work by using a batch file. many thanks.No problem Quote from: Batcher on May 12, 2009, 09:47:19 PM Hi Helpmeh,I can honestly say that I have no idea what that is. |
|
| 4637. |
Solve : was unexpected at this time.? |
|
Answer» I do not use command prompt often so i dont know much about command execution |
|
| 4638. |
Solve : How to combine several conditions in command FOR?? |
|
Answer» Hi everyone,
Thanks you I think you are headed in the right direction. Rather than combine them, why not use a subroutine to do the delete. SOMETHING like: Code: [Select]for /F "usebackq" %%i IN (`net view ^| find /i "BAO-"`) DO call delfiles %%1 goto :EOF :Delfiles set compname=%1 del /q "%compname%\%allusersprofile%\Desktop\*.r2w" goto :EOF Interesting solution, but it does not solve my problem... Your syntax is broken Something like this would be: Code: [Select]set target="c$\Documents and Settings" for /F "usebackq" %%i IN (`net view ^| find /i "BAO-"`) DO call delfiles %%1 :delfiles set compname=%1 for /F "usebackq" %%i IN (`dir "%compname%\%target%\*.r2w" /b /s ^| find /i ".r2w"`) DO set xx=%%i && del /q %%i Thanks for the reply.for /f "tokens=*" %%a in ('net view^|find/i "BAO-"') do del/q/s "%%a\c$\docume~1\*.r2w" REM not testedQuote from: Reno on May 07, 2009, 11:11:24 PM for /f "tokens=*" %%a in ('net view^|find/i "BAO-"') do del/q/s "%%a\c$\docume~1\*.r2w" Thanks, you helped me - I miss, the command DEL is also the syntax "/s" Functional and correct syntax should be as follows: Code: [Select]set prefix=BAO- set target="c$\Documents and Settings\*.r2w" for /F "usebackq" %%a IN (`net view ^| find /i "%prefix%"`) DO del /s /q "%%a\%target%" Caution: The syntax is not valid for the PC, which runs the script!! Limited only to networks in the domain. On the local network in the work group also operates, including the PC, which is activated. That's all folks! |
|
| 4639. |
Solve : IF %username%== ... looking to compare more than 1 at a time? |
|
Answer» Hello, |
|
| 4640. |
Solve : make batch save %var% to .txt and retrieve %var% from .txt? |
|
Answer» i have this program that can run on the command line (goes faster that way) and i have a .bat that makes it easier to do this what i want is to save where it it up to when it exits using a .txt file so that it has an input file and i have this program that can run on the command line (goes faster that way) and i have a .bat that makes it easier to do this what i want is to save where it it up to when it exits using a .txt file so that it has an input file and Ok... echo %var%>filename.txt rem The above line sends the contents of %var% to filename.txt set /p var=rem The above line recieves the contents of filename.txt and sets %var% as it. Understand?it is not writeing to the file but it is reading from it this is my batch Code: [Select]@echo off :setup0 echo do you want to start from where you left off[y\n] set/p "cho=>" if %cho%==y goto setup1 if %cho%==n goto setup2 :setup1 cls echo time set/p "time=>" echo input set /p in=<filename.txt echo %out% echo output set/p "out=>" echo are the time,input and output correct[y/n] set/p "cho=>" if %cho%==y goto evolve_b if %cho%==n goto setup %out%>filename.txt :setup2 cls echo time set/p "time=>" echo input set/p "in=>" echo output set/p "out=>" echo are the time,input and output correct[y/n] set/p "cho=>" if %cho%==y goto evolve_b if %cho%==n goto setup :evolve_b cd C:\Program Files\Evolve evolve_batch evolve_batch s %time% %in%.evolve %out%.evolve %out% is the variable i want to save and i want to make %in% have the value of %out% when i start it againThe easiest way to retrieve a value from a file is Set /P in= Note this will read only the first line of filename.ext and will put the value into %in% Grahamit now reads from the file and saves to the file but not with the value of %out% instead it deletes all the text in the .txt Code: [Select]@echo off & setlocal :setup0 if not exist save.txt goto setup2 echo do you want to start from where you left off[y\n] set/p "cho=>" if %cho%==y goto setup1 if %cho%==n goto setup2 goto:eof :setup1 for /f "tokens=*" %%a in (save.txt) do %%a set out goto:eof :setup2 set/p out=enter string: echo variable out=%out% will be saved as save.txt >save.txt echo set out=%out% sample untested code@ Reno where do you put the code in the batch every time i answer yes to the "do you want to start from where you left off[y\n]" it exits the batch Code: [Select]@echo off & setlocal :setup0 if not exist save.txt goto setup3 echo do you want to start from where you left off[y\n] set/p "cho=>" if %cho%==y goto setup1 if %cho%==n goto setup2 goto:eof :setup1 cls for /f "tokens=*" %out% in (save.txt) do %out% echo time set/p "time=>" echo input echo %out% echo %out% echo output set/p "out=>" echo are the time,input and output correct[y/n] set/p "cho=>" if %cho%==y goto evolve_b if %cho%==n goto setup :setup2 cls echo time set/p "time=>" echo input set/p "in=>" echo output set/p "out=>" echo are the time,input and output correct[y/n] set/p "cho=>" if %cho%==y goto evolve_b if %cho%==n goto setup :setup3 set/p out=enter string: echo variable out=%out% will be saved as save.txt >save.txt echo set out=%out% :evolve_b cd C:\Program Files\Evolve evolve_batch evolve_batch s %time% %out%.evolve %out%.evolve i changed it a bit it would not fit i got headache i only give example how to save a bunch of variables into a txt file and later retrieve the vars the next time batch is executed. for /f "tokens=*" %out% in (save.txt) do %out% <--- incorrect for loop syntax :setup1 <--- let's say this is sort of a "batch function" in OOP term, you have to put goto:eof at the end of each function except the last one, or the the next line of code will be executed Code: [Select]:evolve_b cd C:\Program Files\Evolve evolve_batch evolve_batch s %time% %out%.evolve %out%.evolvewhat are the value of var time,out,evolve,out on the following 2 condition: 1.do you want to start from where you left off[y\n] Y 2.do you want to start from where you left off[y\n] N it would be nice if you can gives example as i don't quite understand the problem. Quote what are the value of var time,out,evolve,out on the following 2 condition:1) time is hours(h),minutes(m),SECONDS(s) or steps(u) so when i type in the time it is 45s(seconds) 30m(minutes) 24h(hours) 4000u(steps) in is the starting conditions of the simulation (in this case it is the previous out file) .evolve is not a variable it is just the files extension out is the output file 2)in this case i set the varables to anything i want to. hmm, maybe something like below works?? Code: [Select]@echo off & setlocal :setup set/p c=do you want to start from where you left off [y\n] : echo.%c%|findstr/ix "y n yes no">nul || goto:setup if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a if /i %c:~,1%.==n. ( set/p var_time=time : set/p var_in=input : set/p var_out=output : set var_>save.txt ) :validateYesNo echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve set/p c=are the time,input and output correct [y/n] : echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo if /i %c:~,1%.==n. goto:setup cd C:\Program Files\Evolve evolve_batch evolve_batch s %var_time% %var_in%.evolve %var_out%.evolvewow Reno that one looked very good but i wanted it to set %var_in% to what %var_out% was last timeCode: [Select]@echo off & setlocal & set c=n if not exist save.txt goto skip :setup set c=&set/p c=do you want to start from where you left off [y\n] : echo.%c%|findstr/ix "y n yes no">nul || goto:setup :skip if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a if /i %c:~,1%.==n. ( set/p var_time=time : set/p var_in=input : ) set/p var_out=output : :validateYesNo echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve set c=&set/p c=are the time,input and output correct [y/n] : echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo if /i %c:~,1%.==n. goto:setup >save.txt echo var_time=%var_time% >>save.txt echo var_in=%var_out% cd C:\Program Files\Evolve evolve_batch evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve CODE UPDATED. CHECK POST #11i wanted it to set %var_in% to what %var_out% was last time it was ran so //first run %var_in%=1 %var_out%=2 //second run %var_in%=2(from save.txt{so i don't need to enter this}) %var_out%=3 //third run %var_in%=3(again from save.txt) %var_out%=4 and so on perfect THANK you so much |
|
| 4641. |
Solve : Characters with accent does not appear in DOS, does not appear in Windows? |
|
Answer» Hi, Hi,Try opening microsoft word, and putting the characters in there. Then save the file as PLAIN TEXT FORMAT (.txt). And you will also need to change your notepad font if you want to view them in notepad, one of the System fonts should do it I think...Hi, Thanks for helping me out. I changed the font style in Notepad to Terminal and it showed up as I expected. Thank you! |
|
| 4642. |
Solve : Findstr s/ "# and other special characters? |
|
Answer» I've searched this site and others and still can't seem to solve this problem - a newbie problem I'm sure. I've tried /l and /C:string but it doesn't fix the problem either. |
|
| 4643. |
Solve : how can i stop batch/cmd from erasing old lines?? |
|
Answer» Quote from: Reno on May 20, 2009, 09:28:36 AM answer: post #2 Worth repeating i chaged the Code: [Select]evolve_b.bat>a.txt to Code: [Select]evolve_batch.exe>a.txt and it now writes this to the .txt Code: [Select] Usage: evolve_batch s <time-spec> <infile.evolve> <outfile.evolve> evolve_batch p <infile.evolve> evolve_batch k <kforth_file> evolve_batch = <file1.evolve> <file2.evolve> evolve_batch rc <file.evolve> [x y] evolve_batch 1S <infile.evolve> <outfile.evolve> ERROR: No arguments. which is some of the text i want to copy i would like to copy this and what is PUT below it Code: [Select]@echo off & setlocal & set c=N title evolve_b if not exist save.txt goto skip :SETUP set c=&set/p c=do you want to start from where you left off [y\n] : echo.%c%|findstr/ix "y n yes no">nul || goto:setup :skip if /i %c:~,1%.==y. for /f "tokens=*" %%a in (save.txt) do set %%a if /i %c:~,1%.==n. ( set/p var_time=time : set/p var_in=input : ) set/p var_out=output : :validateYesNo echo evolve_batch s %var_time% %var_in%.evolve %var_out%.evolve set c=&set/p c=are the time,input and output correct [y/n] : echo.%c%|findstr/ix "y n yes no">nul || goto:validateYesNo if /i %c:~,1%.==n. goto:setup >save.txt echo var_time=%var_time% >>save.txt echo var_in=%var_out% cd C:\Program Files\Evolve >temp.txt evolve_batch.exe type temp.txt type temp.txt>>a.txt >temp.txt evolve_batch.exe s %var_time% %var_in%.evolve %var_out%.evolve type temp.txt type temp.txt>>a.txt notes: with this method, you will lose the real-time display of evolvebatch.exethank you for helping me Reno and i don't care that it does not display the info when it's run i usually leave it going unattended for an hour or so unless i want to save the info (by copying and pasting it in to excel for graphing which i don't have to do any more) so THANK you again for helping me no problem. glad the script works well |
|
| 4644. |
Solve : A little help with batch? |
|
Answer» copy con is an old command that usually used to create a file. copy <file> con will copy a file to the screen. the output cannot be piped, since the output isn't on stdout but rather directly to the output console, the screen.copy con - copy from file to console, great, i never the syntax exist. for clarification, i usually use 'copy con file', not 'copy con>file', a mistake i made in the above post. now if only type 'copy con', whatever i type+enter is displayed twice, so i believe the extra echoed string is save into file when using 'copy con file' Quote from: BC_Programmer on June 03, 2009, 04:59:09 PM the numbers 1 through 3 are actually valid filehandles, and represent the standard Input, output, and error streams.i agree it's actual file handles in windows. but in nt batch, i am sticking with this until i am PROVEN wrong: 1> std-out 2> std-err 3> console not sure about std-in represent what number.CON represents both stdin and stdout- it DEPENDS on the context. for example, copy con would be stdin, since it's reading from con. copy con would be stdout, since it's WRITING to the console. |
|
| 4645. |
Solve : Batch file - Open PDF and Display at 100%? |
|
Answer» Hi everyone. Please forgive my IGNORANCE with Batch files but... Acrobat.exe /A "zoom=100" "my_document.pdf"Don't leave just yeat. Somebody will show up and WRITE a model for you. Thee tow things to resolve. 1. The name and path of the Adobe reader. 2. The name and path of the PD file you want to show Are the PDF files always in the same area? Code: [Select]C:\>type 2pdfdos.bat copy c:\readiris\readiris.pdf "C:\Program Files\Adobe\Reader 9.0\Reader\" cd "C:\Program Files\Adobe\Reader 9.0\Reader\" Acrord32.exe /A "zoom=100" "readiris.pdf"C:\> Output: C:\>2pdfdos.bat C:\>copy c:\readiris\readiris.pdf "C:\Program Files\Adobe\Reader 9.0\Reader\" 1 file(s) copied. C:\>cd "C:\Program Files\Adobe\Reader 9.0\Reader\" C:\Program Files\Adobe\Reader 9.0\Reader>Acrord32.exe /A "zoom=100" "readiris.pdf" C:\Program Files\Adobe\Reader 9.0\Reader> http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/ intro_to_sdk/DeveloperFAQ.pdf#page=27 Quote <<<<"strings). ●printername — The name of your printer. ●drivername — Your printer driver’s name, as it appears in your printer’s properties. ●portname — The printer’s port. portname cannot contain any "/" characters; if it |
|
| 4646. |
Solve : Partition using cmd prompt?? |
|
Answer» To further expand on nothlit's recommendation... I saw you were having some trouble a while back? will try when i have the time. Thanks for your help. really appreciate it ^^ |
|
| 4647. |
Solve : manipulating files? |
|
Answer» Hi All!! but it makes for more readable code in the end, I would imagine.you are right. especially if you have a large project. also, Python doesn't use unnecessary symbols like $,% or open and close braces for if/else, loops...thereby increasing readability of code.Hi all, Thank you for your help. Finally I got the script to run correctly and without error. Below the final script: Code: [Select]import os,glob currentdir = os.path.join("d:\\","receb") os.chdir(currentdir) for file in glob.glob("*.ekt"): firstline = open(file).readline().strip() text = firstline.find("BFT") text2 = firstline.find("MZ7") text3 = firstline.find("PEA") if text >= 0: destination = os.path.join("d:\\","prod") elif text2 >= 0: destination = os.path.join("d:\\","mp") elif text3 >= 0: destination = os.path.join("d:\\","pea") os.rename(file, os.path.join(destination,file)) text = 0 text2 = 0 text3 = 0 I will devote even more to learn this language. Thank you very much even.Quote from: lchbusch on June 04, 2009, 09:12:01 AM Hi all, good for you... some "enhancement" to your script. 1) don't have to use find anymore.. you can use "in" operator 2) next time ,you can use a dictionary to store. eg Code: [Select]paths = { "PEA" : os.path.join("d:\\","pea"), "MZ7" : os.path..... } final code can be shortened: Code: [Select]import os,glob currentdir = os.path.join("d:\\","receb") os.chdir(currentdir) for file in glob.glob("*.ekt"): firstline = open(file).readline().strip() if "BFT" in line: destination = os.path.join("d:\\","prod") elif "MZ7" in line: destination = os.path.join("d:\\","mp") elif "PEA" in line: destination = os.path.join("d:\\","pea") os.rename(file, os.path.join(destination,file)) Dear gh0std0g74, One more time, thanks a lot!! I CHANGED the script as its your indication! I'll see how that dictionaries are used to implement in a new opportunity. |
|
| 4648. |
Solve : Windows Crashed Need To Backup/Transfer/Move files to my External Hard Drive? |
|
Answer» Thank you for your help. |
|
| 4649. |
Solve : For loop Skip=%var%? |
|
Answer» As the title depicts, in a for loop, I need skip to equal %var%. I tried for /f "skip=%var% delims=:" and for /f "delims=: skip=%var%" but it SAYS that it was unexpected at this time.Since you didn't post your code or say what OS you are using we can't see where your problem is Since you didn't post your code or say what OS you are using we can't see where your problem isStrange...it didn't work for me the FIRST time. Quote from: Dias de verano on May 21, 2009, 01:00:49 PM say what OS you are usingIt SHOWS that beside my post... |
|
| 4650. |
Solve : want to remove particular string from a dat file through batch file.please help? |
|
Answer» I have to extract some set of record from the delivery FILE named delivery-2009.6.1-1.10.29172.dat based on the input from another file CALLED component.txt using a batch file having code as below. type delivery*.dat|findstr/sl "%%a">>deliver_results.datfindstr can find MULTIPLE files, so type is not needed Code: [Select]findstr ..... delivery*dat >> results.dat Quote from: gh0std0g74 on June 05, 2009, 01:45:38 AM findstr can find multiple files, so type is not needed dude, it will display the filename in front of the found line when use in conjunction with file mask delievery*.dat. therefore type is needed to pipe into findstr. after testing, i revised a bit on the code, it should be: Code: [Select]type delivery*.dat 2>nul|findstr/sl "%%a">>deliver_results.datCode: [Select]FOR /F "tokens=2* delims=:" %%k in ('findstr /i %%a *.txt') do ( echo %%k >> newfile ) |
|