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.
| 6001. |
Solve : Text parsing help? |
|
Answer» Hi all Maybe there is another approach to the solution?yes there is. The other approach is to use tools like GNU grep.. Then you can use it in your batch like Code: [Select]grep -B 2 "Failed to complete" errorfile > outfile zymos it works on virtually any log - application and iis, the file system, active directory, csv and tab separated format -- and it those all fail, any text format file GrahamJust got grep for windows installed as ghostdog74 recommended and got exactly what i needed. Thanks all for good and FAST reply's. Z |
|
| 6002. |
Solve : Anyone can help me for an simple bat file?? |
|
Answer» I'm newbie in learning the bat file. Just try to use it this 2 days. I'm newbie in learning the bat file. Just try to use it this 2 days.if you want to close a program and you are in XP, you can use taskkill.Quote hmm u seem to not understand what i say carbon dudeoxide.... i just told him thatTalking about your second post, lol -------------------------------------------------- Ghostdog and uli_glueck, kill and taskkill doesn't work for me, Windows XPQuote Ghostdog and uli_glueck, kill and taskkill doesn't work for me, Windows XPwhat is your error messages?? if you search google for "Windows XP taskkill" , the very first result points you to M$ website. So taskkill is definitely a command in XP. Try to check taskkill /?. Or your PATH to DOS commands are not defined. ya, i tried already. The taskkill is a MSDOS command and can use to end an application. Now there is exist another problem, the taskkill only work in window 2000 and xp pro, so the xp home can't use that command. you can always try kill.exe from the windows resource kit. If you don't have the resource kit, you can download here. Or you can download pskill . Not sure if they will work on XP home, but you can always give it a tryHow come taskkill doesn't work for me.......where is it located? e.g. system32you have to get the .exe file carbon dudeoxide and save the .exe into your sys32Nope. It doesn't matter though. |
|
| 6003. |
Solve : locked out of labtop? |
|
Answer» how do i BYPASS the WINDOWS password if i have been locked out. i didn't change my password but my COMP wont recognize the one i use so i can't get in y comp. what do i do?? :-?if you got windows XP.. you can press F8 a bunch of times and go into safemode at startup , |
|
| 6004. |
Solve : erase command....ISSUES!? |
|
Answer» thank u Dias. but everyone plz just tell me would this work.Yes, that should work, but it would also GIVE an error if there were no *.bak files. You could try this: Code: [SELECT]if exist C:\Temp\*.bak (del C:\Temp\*.bak&echo All Bak files have been erased) else echo No Bak files to erasethat you everyone. |
|
| 6005. |
Solve : a simple for loop crashes on Windows XP? |
|
Answer» I have a problem with a customer batch file which I have narrowed down to a one liner. The line in the batch file is: |
|
| 6006. |
Solve : A Password Check? |
|
Answer» Hey, i was WONDERING how i could get some batch to run under xp that WOULD need you to put in a certain right value of characters and when asnwer with the right ones starts a file, when not something else i have in mind, see it as a password check, i tryed it myself in a simple way but it didnt work out, any ideas ?Try this code. |
|
| 6007. |
Solve : Appending text to a file? |
|
Answer» :question :question Use two of > . Example: Code: [Select]echo Backup completed at %time:~0,8% >>"C:\test.txt" One ">" MEANS redirect output the following file, and if it already exists then OVERWRITE it. Two ">", as in ">>" means redirect output to the following file and if it already exists, append to it. Additionally, here is something to try: With > or >> , it is implicit that if the file to write to does not already exist, then create it. Thus, your "copy nul.... " line is not necessary. I hope this helps. |
|
| 6008. |
Solve : Column Cut? |
|
Answer» Hi, |
|
| 6009. |
Solve : Batch to batch? |
|
Answer» I was wondering if there was any way to make a BATCH file modify another batch file? (i.e. add another line of commands to a certain line in a batch file using a different batch file) Either that or how to make a batch file read commands from a text file. (i.e. in text file it says "start test.txt" (w/o quotes) and the batch file reads that from the text file and executes it.) Either that or how to make a batch file read commands from a text file. (i.e. in text file it says "start test.txt" (w/o quotes) and the batch file reads that from the text file and executes it.) You'd have to read the line, parse it, then execute it. Really need to see the specific data. Why are you using batch code for these TASKS? Normal edit like notepad is imposible but you can somethink like this @echo off set /p name=Select name: copy con >%name%.bat or @echo off set /p name=Select name: :A if exist %name%.bat type %name%.bat set /p input=Type your code: echo %input% >%name%.bat goto A To read text.txt and execute "start test.txt" @echo off for /f "tokens=1-3 delims= " %%x in (text.txt) do %%x %%y If something is wrong note that i write this post on cellphone SECOND solution worked perfectly! Thanks! But I don't know if you understood what I meant by the reading the text file and executing it. I might have worded it strangely, but what I meant was in my text file is something like: @echo off start whatever.bat And I was wondering how to run those commands from text files? But again, thanks for the solution to the batch edit!Ok i think i undestood that. Mabey copy txt file to .bat file and use call command? There must be other way but i cant help u right nowOk thanks that worked perfectly!One more question. How do I pull out just a small snippet from a txt file and use it as a variable? Like lets say I want to ping a website, then output the feedback of it into a txt file, then pull just the IP of the website out of that txt file and use the IP address as a variable so I can use the same batch without EDITING for different webpages? LOL i've been trying to find a solution but the 'for' command only seems to be reading only the last line of text.ok got it to make txt a variable, but I need one more thing, how can I replace the last line of text in a txt document with something else? I only need to raplace the last line, anything more and it will mess it up. ThanksQuote from: dragonmaster2091 on January 30, 2008, 02:53:58 PM ok got it to make txt a variable, but I need one more thing, how can I replace the last line of text in a txt document with something else? I only need to raplace the last line, anything more and it will mess it up. Thanksdownload GNU sed for windows here. Then on the command line or batch file Code: [Select]C:\test>type file.txt A,B,C,D,E,F,G this is last line C:\test>sed -e "$d;s/$/\nnew last line/" file.txt A,B,C,D,E,F,G new last line |
|
| 6010. |
Solve : Open and Read from file with MS-DOS? |
|
Answer» I was wondering if anyone knows how to open an existing file and read line by line using MS-DOS? Also does anyone know how to parse out an existing value and replace it with a new value within a file using MS-DOS? there are couple things I want to do....Depends on what you want to do, Code: [Select]gawk "{ #do processing line by line, } " file.txt Quote 2) Second thing I want to do is I have an .ini file that I want to modify. I will need to search for a string, deleted the existing string value and replace it with new string values.Using gawk again code snippet, again depending on what you want to do Code: [Select]gawk " { #read line by line, search for pattern then substitute }" myfile.ini Let me rephrase what I want.... I want to open a file that contains a list of values. Ex values in File: ABC DEF GHI JKL Then read in each value one at a time. Ex. set %value1%=ABC set %VALUE2%=DEF set %value3%=GHI set %value4%=JKL Can MS-DOS automate this? Another way to understand what I want is using DOS to open a file and read in line by line. ThanksMS-DOS, really? What version? Code: [Select]@echo off set idx=0 for /f %%x in (input.txt) do ( call set /a idx=%%idx%%+1 call set value%%idx%%=%%x ) You can try this. I don't remember when the for /f switch was introduced. After running, use the set command at the prompt to see your variables. Good luck. well I am not sure what version of MS-DOS I am using since I have limited access. I know what version of EDITOR in MS-DOS (2.0). As for the for loop... I tried it and it works great. So now instead of 10 pages of code I only have 2 pages of code since I won't have to copy and paste same code over and over again. Thx! |
|
| 6011. |
Solve : Trying to create a bootable thumb drive with DOS OS? |
|
Answer» Does anyone know how to create a THUMB drive that will boot into DOS 6.22? |
|
| 6012. |
Solve : What does ctrl+J do in DOS???? |
|
Answer» I am trying to figure this out to no avail. I THOUGHT it allowed a command to continue to a new line but perhaps not as I cannot get it to work. I am also trying ^ in DOSBox and that is not working either. |
|
| 6013. |
Solve : Green Ivy? |
|
Answer» Help, there is some TYPE of green LEAF and ivy stuff that changes every few days on my screen. My MOUSE goes underneath it? I have run virus scans and they come back clean. |
|
| 6014. |
Solve : help with codes? |
|
Answer» Hello. im a newbie in .bat coding. i just need a LITTLE tips. im gonna *censored* with some friends. but i have a PROBLEM: |
|
| 6015. |
Solve : Redirect Output and Read File? |
|
Answer» Booted to Win98 DOS Floppy |
|
| 6016. |
Solve : help needed with xcopy? |
|
Answer» I’m using xcopy to copy a directory but it asks me if I want to copy the directory or the file, I want this script to run in the background with no human interaction, is there a way to get it to select directory automatically? |
|
| 6017. |
Solve : Games in CMD? |
| Answer» LIKE above. Is there any game coded in batch file ?? EXEPT MINE What's the question ? ?EEE... Is there any game in batch file | |
| 6018. |
Solve : recycled not deleted..? |
|
Answer» this code will delete the recycled files , i just removed about 50 thousand |
|
| 6019. |
Solve : batch file to list log files? |
|
Answer» hello, Thanks, that works. Why didn't the code I was trying work? They seem similar.It MAY have been your /s in the DIR command, or maybe the redirection being "create" instead of "append" Maybe you could have tried @FOR /R %%G IN (*.log) DO dir "%%G" >> "C:\Documents and Settings\chin\Desktop\file.txt"You're right, GuruGary. It works now. Thanks |
|
| 6020. |
Solve : Replace Command???? |
|
Answer» Can SOMEONE show me how the replace COMMAND works? Whenever I use it, it says: No Files Replaced!!!! Help!!!Please show your command LINE ENTRIES. |
|
| 6021. |
Solve : replace search and delete? |
|
Answer» Ok i would like to make a simple BATCH SCRIPT that would search for certain files on my system then delete them without prompt. |
|
| 6022. |
Solve : IF statement? |
|
Answer» Hi,
any help is much appreciated :-) |
|
| 6023. |
Solve : website blocker bypass? |
|
Answer» Ok, I've been workin around and THINKIN about stuff and come up with this code to get passed school website blockers: |
|
| 6024. |
Solve : How Can I Make Avira AntiVir Silent Install ?? What is switch ??? |
|
Answer» Hello .. |
|
| 6025. |
Solve : help creating shortcuts using parameters? |
|
Answer» Hi |
|
| 6026. |
Solve : dos TO wINDOWS nETWORK? |
|
Answer» hOW CAN i LINK AN OLD COMPUTER RUNNING DOS .22 TO A WINxp SO THAT i CAN COPY OVER THE DOS FILES Some flavors of DOS had two utilities you could use along with a compatible cable to connect EITHER the serial or parallel ports in a server/client setting. |
|
| 6027. |
Solve : How to check the IP address are static or not on a remote PC using DOS cmds? |
|
Answer» at work I have a network where some PC's have static IP and most have DHCP. Is there a way I can RUN a btch file to do an audit on the network?You want to tell if the COMPUTER has DHCP enabled or not? Assuming Windows XP, you can run SOMETHING like: |
|
| 6028. |
Solve : How do I make no prompt for deleting files?? |
|
Answer» I'm making a short little file so that I can put in SCHEDULED Tasks to run EVERY night, but I when I try to DELETE Windows Temporary Files it gives me a prompt, here's what I get. |
|
| 6029. |
Solve : One or more CON code pages invalid..? |
|
Answer» I get this message every time I run cmd: "One or more CON code pages invalid for given KEYBOARD code". |
|
| 6030. |
Solve : HELP FIXING XP's CORRUPT STARTUP FILES W/RECOVERY CONSOLE? |
|
Answer» I am trying to repair a Win XP PRO installation using recovery console. On many XP installations you can't start the Recovery Console because it won't RECOGNIZE your password. This registry edit causes the Recovery Console not to ask for a password. This works for both XP Home and XP Professional. I thought MS had sorted out this problem with a hotfix, are you fully updated? Unfortunately this is of no help to you at present. There are several good bootdisks (cd) which will read/write in the NTFS file system and allow you to reinstall files. NTFS4Dos is one I have used with good results. FYI on my system there is a copy of NTOSKRNL.EXE in C:\Windows\System32\dllcache\ Good luckJust hit the enter key without entering a password ( as is working right now on a machine with no admin password |
|
| 6031. |
Solve : using wildcard - file name as variable? |
|
Answer» so I have files and im not sure about the title of what it is, it could be anything from 001.money to 999.money. I want SET to read the file that ends with .money. then after that can I make it so that money=100 instead of money=100.money? heres the code I have so far but not working. Im not sure if ?'s are wildcard in DOS but I also tried with a single *. I want SET to read the file that ends with .money Not sure what you mean by "want SET to read the file" but if you just want to RENAME the files..... try: Code: [Select]@echo off cls set money=001 :LOOPING if exist %money%.money ren %money%.money %money% set/a money=%money%+1 if %money% gtr 999 goto end goto looping :end not really, i just want the number imported and set as %money% and then eventually I will rename it to %money%+5 or whateverI forgot about the octal problem with set/a so the .bat SCRIPT won't work anyway. If I understand your goal CORRECTLY, I think you want something LIKE: Code: [Select]for /f %%a in ('dir *.money /b') do set money=%%~na echo Money=%money% |
|
| 6032. |
Solve : Why, Why, Why.? |
|
Answer» Hello everybody, Widows do run without DOS. The last version of windows that was built on top of DOS was Windows ME. In all later version DOS is merely emulated (poorly) for the sake of backwards compatibility. Do not confuse the command prompt present in win 2k/XP/Vista with MS-DOS. The command prompt provides a text based interface (similar to DOS) for cases where text based access might be more practical than a point and click GUI. So the command prompt might look and feel like DOS but it is an application written for Windows just like Paint or Calculator, not an operating system. Thanks Deerpark, that has cleared up some confusion that I had. One more question, What would be the best thing to use the command prompt for. Hmm it is hard to say what the CMD is best for... Basic network diagnostics is usually done in cmd because the TOOLS available in Windows doesn't have a GUI. Batch jobs are also run in the cmd. Thanks again Deerpark, cheers for the input!Glad I could be of service. |
|
| 6033. |
Solve : Running a net functiom from a batch file ????? |
|
Answer» i want to RUN a "net USER admin" function and keep it printed on SCREEN without having to TYPE it in to the MS-DOS myself |
|
| 6034. |
Solve : Scheduling Shutdown? |
|
Answer» Hi all, I think I'm the first one who thought to schedule Shutdown (please tell me I'm wrong) so can I still do it? you not the first. I use a bacth file to restart my servers for windows updates out of office hours of course (and before the backups run!!!) below is said bacth file (nice and easy..) Code: [Select]shutdown /r /t 5 /c "Apologies for any inconvenience." /f /d p:4:1 you'll want to remove the /r as that will restart said machine. I've added it as a scheduled task and when ever i want to run it i just schedule it for that night. easy.Hi blastman and all, no not even that didn't work with me, it still cannot be added to the Schedule Task. Would anyone suggest me moving to the Windows Forum? 'cause no one here thinks it's a command error. ThanksI would try a program called Switch Off. You can tell it to shut down at what ever time and close any programs that are open. You can also set up a MESSAGE in it say that it going to shut down. I find it alot easier to use.Quote when I try to "open advanced properties I'm uncertain what these advanced properties you speak of are, but sometimes brute force works too. Code: [Select]at 10:30PM /every:m,t,w,th,f,sa,su "shutdown.exe -s -t 03 -f" Enter the above command from the command prompt. The job RUNS under the NT Authority/System user and should set you right up. The job name will be AT#. Note: The GUI scheduler and the AT command use two different API's. Jobs scheduled with the GUI cannot be seen by the AT command but jobs scheduled with the AT command can be seen by the GUI.Hi Sidewinder, thanks for your line but that also didn't work and yielded a "Could not start" status in Scheduled Tasks. The Advanced Properties that I've talked and you asked about are those of the task itself when you create a new one using the "Scheduled Task Wizard", after several "Next's" and before the "FINISH", you'll be prompted to literally "Open advanced properties for this task when I click Finish". There was no other information besides "Could not start"? What code is in the last result column? Did you check the event log, there may be more INFO there. Who is logged onto this machine when the shutdown starts? NT Authority jobs should run no matter who is signed on. On the property sheet for the scheduled job, check the task tab. What is in the RunAs box? Is the Run Only If Logged On box checked? If not you must supply a password for the account. The enabled box must be checked for the job to run. Hooray Sidewinder, at last it works and finally I can get my daily sleep! The catch was that, by default, the Run Only If Logged On box was unchecked so I checked it. Thanks |
|
| 6035. |
Solve : how to format ur hard drive? |
|
Answer» that MAYBE true but he may have a wireless keyboard and mouse that connect to a USB port. now the motherboard's ROM may work with the USB keyboard and mouse without the DRIVERS but the main thing is we should stop arguing. and help ukperi. that maybe true but he may have a wireless keyboard and mouse that connect to a USB port. now the motherboard's ROM may work with the USB keyboard and mouse without the drivers but the main thing is we should stop arguing. and help ukperi. Now you're arguing semantics aren't you ? ? I'm done here. |
|
| 6036. |
Solve : 10 seen as 1? |
|
Answer» HEY all, I've got a loop that runs a installation app on remote machines. I've set it out like this; Code: [Select]set count=1 :loop if /i %count% EQU 1 (set pc=nameofpc) if /i %count% EQU 2 (set pc=nameofpc) if /i %count% EQU 3 (set pc=nameofpc) if /i %count% EQU 4 (set pc=nameofpc) if /i %count% EQU 5 (set pc=nameofpc) if /i %count% EQU 6 (set pc=nameofpc) if /i %count% EQU 7 (set pc=nameofpc) if /i %count% EQU 8 (set pc=nameofpc) if /i %count% EQU 9 (set pc=nameofpc) if /i %count% EQU 10 (goto end) net use \\%pc% installation code here.... set /a count +=1 goto loop :end script complete exit my issue is that when count reaches 10 the if statement only See's it as 1, so instead of going to :end to redoes the first PC again. I've changed the numbers so they read 0-9 so it works, but I'd like to add another PC to it and I'm a little LOST as to why it is happening. NOTE; I have also tried putting " " around the number but that hasn't helped. any ideas???Seems %count% always has a value of 1 as it's never updated. The line "set /a count =+1" maybe should read "set /a count=%count%+1" Thanks for the reply. %count% ADDS an extra 1 every time passes 'set /a count +=1' fine. (i have added an 'echo %count% just before it trys to map to the PC, so I know which one it is doing) The problem is that after it gets to 9, it adds another one (becomes 10) but the 'if' statement fails to see it as 10 and See's it as 1 so it does the first PC again. As i said, I have changed the numbers to read 0-9 so that this isn't an issue at the mo and it works fine. But I'm going to have to add another PC withing the next few days so I'm trying to find an answer!!!!Sorry, I was wrong, but I have been unable to replicate your problem, there's just gotta be something else. I butchered your coding slightly as below and it runs without hitch. No problem with the IF statements picking up numbers >9. Code: [Select]set count=1 :loop if /i %count% EQU 1 (set pc=nameofpc) & echo %count% if /i %count% EQU 2 (set pc=nameofpc) & echo %count% if /i %count% EQU 3 (set pc=nameofpc) & echo %count% if /i %count% EQU 4 (set pc=nameofpc) & echo %count% if /i %count% EQU 5 (set pc=nameofpc) & echo %count% if /i %count% EQU 6 (set pc=nameofpc) & echo %count% if /i %count% EQU 7 (set pc=nameofpc) & echo %count% if /i %count% EQU 8 (set pc=nameofpc) & echo %count% if /i %count% EQU 9 (set pc=nameofpc) & echo %count% if /i %count% EQU 10 (set pc=nameofpc) & echo %count% if /i %count% EQU 11 (set pc=nameofpc) & echo %count% if /i %count% EQU 12 (set pc=nameofpc) & echo %count% if /i %count% EQU 13 (set pc=nameofpc) & echo %count% if /i %count% EQU 14 echo %count% & (goto end) :: net use \\%pc% :: installation code here.... set /a count +=1 goto loop :end :: script complete :: exit I always surround both sides of IF tests with QUOTES & use double equal signs rather than EQU & I never have this problem. Also, why the parentheses around "goto end"? if /i "%count%"=="10" goto end Quote from: Dias de verano on February 28, 2008, 05:44:34 AM why the parentheses around "goto end"? Force of habit really. I usually have '(goto end) else goto wherever'. I'll have another look at my code later this afternoon.Quote from: blastman on February 28, 2008, 06:41:10 AM I usually have '(goto end) else goto wherever'. That's a good tip. Thanks! well, I've added " " to numbers over 9 (ie. more than one didget) and it seems to have done the trick!! I had done originally and then changed it cos I though it was causing other errors. I must have had it wrong. I've stuck it on a server, scheduled it to run and put it to bed. - (hopefully) job done. Thanks |
|
| 6037. |
Solve : how to verify the native language of MS XP PRO in DOS? |
|
Answer» Hi all |
|
| 6038. |
Solve : DOS and ur Modem? |
|
Answer» is it possible for DOS to Dial ur modem(yes, a Dial-Up modem) to a specific phone number like if you have ur phone connected to ur modem? Quote from: macdad- on March 16, 2008, 09:46:57 AM is it possible for DOS to Dial ur modem(yes, a Dial-Up modem) to a specific phone number like if you have ur phone connected to ur modem? Back when we all used MS-DOS, there were MANY programs out there for dialing and connecting. Same for receiving and connecting. Some were free, some were shareware, some were commercial software. I liked Telix. Still keep a copy handy... just in case I want/need it. It is uncrippled shareware. You can download it here: http://www.chebucto.ns.ca/Services/PDA/DosComm.shtml If, after reading the docs, you are not sure what to do with it, post here and I'll try to help. Bear in mind that it has been quite a while since I last set it up from scratch, so I might stumble a bit. It is REALLY not very difficult though. I don't know what os you are using - assuming XP. I don't know about XP and its command line, as to how it likes an old fashioned DOS program wanting to control a serial port. You might have to get advice on that part from the XP folks here on CH. You'll need to post the brand name, make, mode number, whatever, of your modem too. What is it that you are trying to accomplish though?yes, that is just wat i need thnx! Quote from: macdad- on March 16, 2008, 01:18:29 PM yes, that is just wat i need thnx! You're welcome. Telix was a very nice terminal program for its TIME. What is it that you are trying to do though?well i have a DSL modem already but i needed a program that could Dial my ISP using my Dial-Up Modem in the case that my DSL modem was down.Quote from: macdad- on March 16, 2008, 01:39:59 PM well i have a DSL modem already but i needed a program that could Dial my ISP using my Dial-Up Modem in the case that my DSL modem was down. Dialing your ISP is probably not enough. You have to have a meaningful connection too. Unless your ISP allows a shell account, and they probably don't, Telix won't do what you need. For example, you want to be able to browse the web, right? Win98 had Dial Up Networking for this. I assume that XP has it too. That's what you want to negotiate a connection that will let you use the internet with your ISP. On the other hand, if you wanted to dial a friend's computer direct, then Telix would be useful. If you both run Telix successfully, you could connect over a regular dial up phone line. Transfer files, 'chat', etc. As a matter of fact, if I recall correctly, that Telix package included some scripting that would let Telix auto-answer and allow the caller to log in. Bare bones bbs software. well does Telix allow you to send data? if so then all i do is dial up my ISP then i send the username and password data thats how my ISP functions with Dial up conncection,simply dialup the ISP then send the username and password data.Quote from: macdad- on March 16, 2008, 01:52:48 PM ... So how did that work out for you? yup, WORKS lke a charm. ty |
|
| 6039. |
Solve : Calling a command window to run in the background? |
|
Answer» Thanks to those who helped me on my previous problem with my batch FILES and calling up command windows. The shell program WORKS great, now the only downfall is that when the command windows CALLED up by my batch file open, they are always the focus or active window. Is there any way to call them up so they will not keep jumping to the top layer on the screen? I ASK this because right now it takes about 3 hours to run the program that my shell is utilizing so it essentially MAKES that computer unusable for 3 hours. Thanks for the help.Try this: start /min yourfile.batJPH's suggestion should work. |
|
| 6040. |
Solve : Select and Delete Files older than 2 Weeks and 1 Month? |
|
Answer» Hello. Would anyone know how to : 1. do a count of files in a DIRECTORY 2. output count to a txt file 3. and then delete files that are older than 2 WEEKS? 1 month? Thanks.The first 2 are easy, the last really needs to be done with VBScript - batch files really dont do date manipulation. The count can be taken using the FIND command, COUNTING the output from a DIR dir /b /a-d|find /c /v "" > CountOfFiles.txt the dir shows basic info about all files that do not have the attribute Directory The find then provides a count of all the lines that do not contain a blank (ie those that have something in) It then directs the count into the file CountOfFiles.txt GrahamQuote The first 2 are easy, the last really needs to be done with VeBScript Might as well get the VBScript while you're here. Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("c:\scripts") 'Start directory Set colSubFolders = f.SubFolders For Each objFolder in colSubFolders AgeFiles objFolder Next Sub AgeFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If objFile.DateCreated < date - 30 Then 'Age factor Wscript.Echo objFile & " " & objFile.DateCreated End If Next For Each SubFolder In s AgeFiles SubFolder Next End Sub Change the start directory and age factor to your needs. The script uses recursion, any subdirectories of the start directory will also be processed. As a safetly PRECAUTION the script reports back the aged files. When you're ready replace Wscript.Echo objFile & " " & objFile.DateCreated with fso.DeleteFile objFile |
|
| 6041. |
Solve : Open url direction from MS-DOS? |
|
Answer» HI there! Does anyone know how to open an url direction from MS-DOS? Thank youWhy the poll? What exactly do you WANT opinions on? Don't you find it odd that both choices are IDENTICAL? Perhaps this will help with your COMMAND line URL: Code: [Select]"C:\Program Files\Internet Explorer\iexplore.exe" http://www.google.com Quote from: Sidewinder on March 19, 2008, 06:26:45 AM <sigh> |
|
| 6042. |
Solve : Set command? |
|
Answer» how do u do math using the set command? thnx Dusty it worked. GOOD, but be aware that if the hour in %Time% is less than the number of hours to be deducted you must use base 24 i.e. add 24 to the hour in %time% before deducting. e.g. if the current hour is 11 and you deduct 12 then you will get -1 whereas you really wanted 23 but 11+24-12 is 23. Similarly when manipulating MINUTES and seconds base 60 must be used. However, another problem(?) is that when SET/A encounters a number beginning with 0 (zero) it treats it as Octal (base eight). So if you try to do arithmetic calculations using SET/A on 08 or 09 (zeroeight or zeronine) the number is invalid in base 8 so the script will fail. My solution is to always remove the leading zero from numbers less than 10 (when dealing with two-digit numbers). Good luck & thanks for coming back with your success story. |
|
| 6043. |
Solve : How to specify a filename or foldername with space in batch file? |
|
Answer» Can somebody HELP me how to WRITE a CODE in DOS batch file for a filename/foldername with spaces?quote marks Can somebody help me how to write a code in DOS batch file for a filename/foldername with spaces? Examples - This line won't work here (Win98) : cd\test\dir name with spaces This line does work: D:\>cd\test\"dir name with spaces" D:\test\dir name with spaces> Yes. But what if part of the file name (i.e. "Report 2008 April.xls") needed to be calculated based on the current date? How could the string be CONCATENATED? Thanks in advance! |
|
| 6044. |
Solve : 1/100 chance of something? |
|
Answer» When working on Eternal Death Slayer Version 2, I thought it would be cool if there is a chance of something you dont expect, so i decided on a 1 out of 100 chance that a monster attacks you when you GO to the lobby, although when i inserted the code, all it did is make the WINDOW close. Here's my code: |
|
| 6045. |
Solve : create a folder by date? |
|
Answer» PLS HELP me create a batchfile for backup that will create a folder by DATE so that the backup will be overwritten. sample command " test 020409 " where test=batchfile, 020409=mmddyyHave you tried the HANDY SEARCH function at the top of the page ? Folder Date Returns many useful threads on this Graham |
|
| 6046. |
Solve : Create folder from Volume name? |
|
Answer» I want to copy numerous CD's to a server. I want to place the files from each CD into a folder named after the CD Volume name. |
|
| 6047. |
Solve : Xcopy Exclude? |
|
Answer» Need help on syntax for Xcopy Exclude |
|
| 6048. |
Solve : how to create a batch file which gives us mail notification on application failu? |
|
Answer» HI all, I want to create this as batch file as my application is on windows If you're monitoring only the xyz application, you can check the errorlevel and use BLAT to send a batch email. It is possible to create a VBScript to monitor program terminations system wide, however, I could not find a property to CAPTURE a return code which might indicate success or failure. Good luck. Oh yeah, have you ever tried Blat. Because I tried it last time and it didn't work with me. |
|
| 6049. |
Solve : osql to MSSQL? |
|
Answer» Is there any EXPERT who knows how to send a log to a designated MSSQL DB when a BATCH file completed by MS DOS. The log should containing CLIENT IP ADDRESS, Datetime etc.... |
|
| 6050. |
Solve : Prompt for user input of file? |
|
Answer» I need to execute specific files based on a Change Request. The files names change with every change request. The directories where the files reside changes from time to time as well, depending on the version being DEPLOYED. There are usually many files residing in each version directory. Currently I COPY the FILE to a separate "staging" directory, but I was WONDERING what I would need to add to my batch file to prompt the user to insert the directory name\file name in the command window so it can execute that specific file without having to copy the target file to a separate directory?Try this |
|