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.
| 8751. |
Solve : how can i find windows folder ?? |
|
Answer» hi how can i find windows folder and switch dir to it ?Code: [Select]c: CD \. cd %SYSTEMROOT% Quote how can i store date in txt (or else) file and restore date in txt ( or else ) file ?Code: [Select]echo %date% > file.txt I am not sure how to set date based on contents of file. |
|
| 8752. |
Solve : Batch File Help---Is this possible?? |
|
Answer» Can someone please help me create a batch file that will either wait for a program to finish unrar a file then open imgburn and burn it or if it would be easier a batch file that will run if a download is complete unrar the file, then run imgburn and burn the files. |
|
| 8753. |
Solve : Moveing certain files to certain folders? |
|
Answer» I have WELL over 3000 songs on my computer so going through them one by one is really not an option. I want to move all my files that say contain "James Otto" in the NAME to the "James Otto" folder and move say all files with "Creed" in the name to the "Creed" folder and so on. I know that it'll take time to write the .bat file but it will be quicker than going through two different hard drives and trying to move them all over to one drive and in their respective folders. Thanks in ADVANCE!!Why move files? |
|
| 8754. |
Solve : If SET goto? |
|
Answer» hi |
|
| 8755. |
Solve : simple help with .bat files please? |
|
Answer» hello. |
|
| 8756. |
Solve : Help with a batch file & date last modified? |
|
Answer» Wish list @echo off If you are still 'here', tell me if that works as expected, thanks.By looking at DeltaSlaya's code, I think it will copy all files (although in order of date) and I think it requires that the current directory be the SOURCE directory. To copy only the last modified file, I think you could do Code: [Select]@echo off setlocal for /f "delims=" %%a in ('dir C:\Source /a-d /od /b') do set recentfile=%%a copy "C:\Source\%recentfile%" "C:\Destination"Quote from: GuruGary on September 08, 2007, 07:32:00 AM By looking at DeltaSlaya's code, I think it will copy all files (although in order of date) and I think it requires that the current directory be the source directory. To copy only the last modified file, I think you could do No, and no. As you can clearly SEE it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir.Quote from: DeltaSlaya on September 08, 2007, 03:22:11 PM No, and no. As you can clearly see it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir. OK, sorry. I do see that it will only copy the last modified file, but I still think it will only work if the file EXISTS in the current directory. If you change Code: [Select]copy "%%I" "%outdir%"to Code: [Select]copy "%indir%\%%I" "%outdir%"then I think it will work.here's a vbscript Code: [Select] ' ***************************************************************** ' * Name: CopyLastModifiedFile.vbs * ' * Function: Copy last modified file to target folder * ' * Inputs: * ' * ARGUMENT 1: Source Folder where files need to be copied * ' * Argument 2: Destination Folder to copy files to * ' * Usage : c:\> cscript /nologo CopyLastModifiedFile.vbs src dst * ' ***************************************************************** Option Explicit Dim objArgs,objFSO Dim I ,SrcFolder, DstFolder,temp,myFile,FileName,ShortName Set objArgs = WScript.Arguments SrcFolder=objArgs(0) 'first arguments is source folder DstFolder=objArgs(1) 'second argument is destination folder temp=0 Set objFSO=CreateObject("Scripting.FileSystemObject") For Each myFile In objFSO.GetFolder(SrcFolder).Files If myFile.DateLastModified > temp Then 'get the lastest modified file temp=myFile.DateLastModified FileName=myFile ShortName=myFile.ShortName End If Next objFSO.CopyFile FileName, DstFolder&"\"&ShortName 'copy to destination Set objFSO=Nothing Set objArgs=Nothing Quote from: GuruGary on September 08, 2007, 10:40:54 PM Quote from: DeltaSlaya on September 08, 2007, 03:22:11 PMNo, and no. As you can clearly see it only gets one file because the loop is only initated once and then the code at the :done label is executed. It does not require the source directory to be where you get the files from, thats why there is a clearly labeled variable that you set, aptly named indir. Oh sorry my bad I left something out. Quote @echo offThanks to you all. I have a simple .bat that works Xcopy C:\PROG P: /A/Y Xcopy C:\_Labels L: /M/Y Xcopy C:\PROG C:CNC_OFF /A/Y Pause I paused the batch so we can see if the machines were off. I know this requires another tap of the key. I feel more comfortable that others will CATCH a folder that isn't available. PROG and _Labels are folders on my C drive. I see that you all are all more at ease with this than I. Thanks for the replies. For me, it worked with... set sourcedir=sourcedir set targetdir=targetdir for /f "delims=" %%I in ('dir %sourcedir% /b /a-d /od') do set targetfile=%%I copy %sourcedir%\%targetfile% %targetdir% Regards.Hi, Quote for /f "delims=" %%I in ('dir %sourcedir% /b /a-d /od') do set targetfile=%%I i dont understand this command at all, can someone explain it to me and how to use it? thanks. |
|
| 8757. |
Solve : call one batch file from another? |
|
Answer» i have 2 batch files -- B.bat containing - |
|
| 8758. |
Solve : Embedded for loop.? |
|
Answer» Quote from: BETTY on August 27, 2011, 03:36:08 AM @Ghostdog74 - Thank you for your interest. yes, it does this (File 1) Line A Line B (File 2) Line 1 Line 2 Output Line A Line 1 Line B Line 2 You can select other delimiters than the dafault TAB but essentially that's what it does I think. If the delimiter could be CR/LF that might be a solution? Yes, salmon is right, if Betty wants to intersperse the lines, Code: [Select]paste -d "\n" fileA.txt fileB.txt Otherwise, the default places the lines "side by side"Quote METHOD 1 (straight code, no subroutine, process all lines of File2 for each line of File1) 83 seconds Hi Salmon Trout, Could you please help test the performace of this one: Code: [Select]@echo off setlocal enabledelayedexpansion (for /f "delims=" %%a in (file1.txt) do ( set /p _f= echo,%%a echo,!_f! ))<file2.txt >file3.txtQuote Both files CONTAIN the same number of lines. I understand the OP SPECS, but what if the files are of unequal length? Batch code does not support arrays, however borrowing from REXX, you can mimic the stem.tails technique. I'm also a big fan of prompts for non-automation scripts. Makes them more generic. This is an alternate approach, nothing more: Code: [Select]@echo off setlocal enabledelayedexpansion :file1 set /p file1=Enter File 1 Label: if not exist %file1% goto file1 :file2 set /p file2=Enter File 2 Label: if not exist %file2% goto file2 for /f "tokens=* delims=" %%y in (%file1%) do ( call set /a idx=%%idx%%+1 call set array.%%idx%%=%%y ) set array.0=%idx% for /f "tokens=* delims=" %%i in (%file2%) do ( call set /a index+=1 if !index! LEQ %array.0% ( call echo %%array.!index!%% >> c:\temp\merged.txt ) call echo %%i >> c:\temp\merged.txt ) if %index% LSS %array.0% ( for /l %%i in (%index%, 1, %array.0%) do ( echo !array.%%i! >> c:\temp\merged.txt ) ) Powershell and VBScript can also be used with varying degrees of simplicity. Quote from: CN-DOS on August 31, 2011, 05:20:18 AM Could you please help test the performace of this one: What performance result did you get? I used timeit.exe to count the time, and 1000 lines for each file. Method 3 of Salmon Trout: Elapsed Time: 0:00:06.364 Process Time: 0:00:04.368 Method of CN-DOS: Elapsed Time: 0:00:00.468 Process Time: 0:00:00.265 BTW, the PMs from NatHeim are realy boring. Is it possible for moderator to disable him to use PM? Or does this forum have black list function, so I can put him in it?Method of CN-DOS 0.38 seconds elapsed time. In your profile you have an Ignore list |
|
| 8759. |
Solve : executing batch files in subdirectories? |
|
Answer» I know that you can execute a DOS command in sub-directories by using the /s switch at the end of a command. |
|
| 8760. |
Solve : Rename folders? |
|
Answer» We have 5 sets of backups, each in a different folder, IE; |
|
| 8761. |
Solve : creating escape sequences on laptop? |
|
Answer» I just found out about ESC sequences and was wondering how one can create one [m23, ( I believe is Alt-27) on a laptop easily. I think doing them on a desktop is much easier as you can use the NumPad at the right. |
|
| 8762. |
Solve : Batch File With NO LABLES? |
|
Answer» @ECHO OFF May we have an example? Well, I'm sure someone else could cook up a better example but here's one: Batch 1: Code: [Select]@echo off SET /p ANS=Choice? IF "%ANS%"=="Y" ( CALL bat2.cmd ) IF "%ANS%"=="N" ( CALL bat3.cmd ) Batch 2 (bat2.cmd) Code: [Select]echo You called Yes! pause >nul Batch 3 (bat3.cmd) Code: [Select]echo You called No! pause >nul By answering yes or no, you branch out by calling other batch files instead of jumping to labels. Again, I don't know why you would want to take this route as it is tedious and unreasonable.You can eliminate the calls with something LIKE this: Code: [Select]@echo off setlocal set /p ans=choice? if /i "%ans%"=="y" echo You Called Yes if /i "%ans%"=="n" echo You Called No pause > nul Agree with previous POSTER, batch code is already obtuse and obscure so why make things more difficult for yourself? Quote The above code does nothing. Of course not, it was in response to the previous poster as a alternative to using calls. The OP apparently wants to eliminate :labels. The following snippet accomplishes that, but READABILITY plunges near zero. Code: [Select]@echo off setlocal set /p ans=choice? if /i "%ans%"=="y" (echo You Entered Yes && echo Whooppee - isn't this exciting! ) else if /i "%ans%"=="n" (echo You Called No && echo How Negative! ) else (echo Invalid Entry, Try Again && %0) Just curious why OP doesn't want to use all the features available. |
|
| 8763. |
Solve : BATCH FILE ICON? |
|
Answer» Is it POSSIBLE to change a batch file's icon?? |
|
| 8764. |
Solve : Win 7 32bit & Simple Batch Issue..Wild Card *.* not operating?? |
|
Answer» xcopy "c:\users\dave\application data\runic games\*.*" c:\games_backup\*.* /s/d/y C:\04_2011>robocopy "c:\users\dave\application data\runic games" c:\games_backup /E /IS |
|
| 8765. |
Solve : Send and recive SMS in Dos os? |
|
Answer» HI i want to send and recive sms in DOS os. but i dont know how to do it. pleas help me You will need to write a program to do it, and in a language that can be executed in DOS like an old version of C++ pre dot.net for example. You also need to know how SMS works, protocol and all. SOMETHING like this would be quite the project for someone to take on, not just a small quick program one of us here would be ABLE to POST up here for free as open source. http://en.wikipedia.org/wiki/SMS Hi Mr. Davelembke. tanks for your answer. i wrote a program with DELPHI that it work with GSM modem And cell phon. you can download it from my web www.abshar-system.ir but it is persion language. i dont want to write a full software. i want writ a dll or small software that it can send SMS and USD and Recive them. i cant use AT Command in DOS . can you help me Pleas?Hi evryone. no body can help me? |
|
| 8766. |
Solve : Batch Programming Book? |
|
Answer» Hi guys, well am asking if there is anyone knowing where i can get the best batch programming book Hi guys, well am asking if there is anyone knowing where i can get the best batch programming bookCan i ask why are you learning batch? because i want to suggest to you to start with something better like vbscript or powershell (if you absolutely must work on Windows) or Python,Ruby,Perl (for cross platform system administration). Quote from: ghostdog74 on August 26, 2011, 11:45:12 PM I want to suggest to you to start with something better like vbscript or powershell (if you absolutely must work on Windows) or Python,Ruby,Perl (for cross platform system administration). These are wise words. Quote from Raymond Chen's blog, The Old New Thing yesterday: He offered a TIP for Windows users to count the lines in STDIN like wc -l in *nix (some-command-that-generates-output | find /c /v ""), and explained how it arose because of a bug in find.exe that had to remain (as a feature) because batch scripts had been written that took advantage of it. (Due to an integer underflow bug, a string of length zero was treated as if it were a string of length 65536, which doesn't match anywhere, thus the null string never matches, and its negation always matches) Quote (REMEMBER, I provide the occasional tip on batch file programming as a public service to those forced to endure it, not as an endorsement of batch file programming.)well...thank u all for your great participation and the reason i want to study batch programming isn't quite clear but honestly its just for fun! and sure i'll study all of the other languages but just to start with batch programming cause i kinder love its scripts!!You go right ahead... have fun! Salmon Trout and ghostdog74 i thank u alot!!..i have found the book u send me a link and yeah..thank u guys very much!! In case you didn't have this: Command-line reference A-Z http://technet.microsoft.com/en-us/library/bb490890.aspx |
|
| 8767. |
Solve : Replacing long filenames with wildcards in Windows 7? |
|
Answer» Hi all, I'm trying to create a batch code to copy some information from one drive to another every time my PC starts up and I'm having trouble with the syntax. The error message I'm getting seems to be referring to the destination location, and says "The network name cannot be found". When using the universal naming convention (UNC) the format is \\server-name\shared-resource-pathname. Either Server2 is not correct, or 'Directory2 Long Filename' is not a shared resource. Note: you can also use ADMINISTRATIVE shares (format: drive$) in place of the shared-resource-pathname, but you must get the server name correct. Check to see if you're connected to the server and what resources are shared. You notation with the quotes is correct, so you shouldn't need to use short names. Hope this helps somewhat. Thanks for the CLARIFICATION, I went back and had a look at from a DIFFERENT angle and I'd been a muppet and missed out part of the destination path. Thanks all for your help! |
|
| 8768. |
Solve : Moving a file in dos? |
|
Answer» Can someone help me out on this I know I missing something. I WANT to move a file "l.jpg" on my DESKTOP to a folder "TEST" on my desktop. this is the output of my request. |
|
| 8769. |
Solve : Command line to create a folder with the name of a file? |
|
Answer» Friends, friends... I don't know if it is possible. But it will be of great help. |
|
| 8770. |
Solve : need to automate sqlldr call? |
|
Answer» hi dear friends, |
|
| 8771. |
Solve : Moving many files in many folders to a single folder? |
|
Answer» Without buying a utility program I need to move many files in many folders to a single folder. I think there is a ms command but am not sure about the exact syntax. Can someone format the command line for me where I can simply insert the directory information? I would also like to retain the original file dates. I am using XP. Thanks in advance and am sorry for not being very pc LITERATE. Quote from: Bluescoot on April 07, 2011, 08:25:21 AM Without buying a utility program I need to move many files in many folders to a single folder. I think there is a ms command but am not sure about the exact syntax. Can someone format the command line for me where I can simply insert the directory information? I would also like to retain the original file dates. I am using XP. Thanks in advance and am sorry for not being very pc literate. copy /? move /? xcopy /? Something like this might help... Code: [Select]@echo off set /p mainfolder=What is the main folder? echo Type all the other folders, pressing enter after each one. Type exit to stop. :again set /p otherfolder=Other folders? if %otherfolder%==exit goto :eof xcopy %otherfolder%\*.* %mainfolder% goto again I got some help on the copy command. Still UNSURE of my syntax. Can anyone review my attempt below ? I am attempting to copy all my mp3 files on my hard drive E:/Allmusic/ multiple folders To E:/all music/new files Will this consolidate all the files to one folder? If successful I'll go back and delete the old directories and files. COPY [/-Y] [/E:/all music/[+ ...]][[/E:/all music/new all files/[+ ...]]Quote I need to move many files in many folders to a single folder.Wrong! The question is wrong. There is not provision for such a thing. You need too restates the question. Files could be reamed and moved, but you question did not allow for that. Before getting the right answer, you haven to ask a question that conforms to the structure of the files system. Consider: If a files system required all files to have an unique identifier, there would be few reasons to have folders. In fact, there are such files systems. However, the path is, effectively, part of the unique ID of any file in Windows. (And also and many other OS.) The question suggests muddled thinking or lack of insight. Otherwise, if the OP can state a clear objective as to why many files need to appear visible as if they all were part of one group, clas, FAMILY, collection or genure, then a clear precise answer can be provided. Or, to put it another way, Imagine you went into n bookstore and all the books have the save name. Is that within reason? Quote Student: I want the book 'war and Peace.' |
|
| 8772. |
Solve : Batch files: Usable only on a certain date?? |
|
Answer» I don't know if it's even possible, but I desperately need to know how to make a batch file with text that you can see only once it is a certain day, like making it not work until April 8th or something.Please POST the format of your local DATE variable that you see when you OPEN a command prompt and type ECHO %DATE% and press ENTER. C:\>echo %date% Code: [Select]@echo off if "%date%"=="SUN 04/10/2011" ( echo You will only see this on Sunday 10th April 2011 ) |
|
| 8773. |
Solve : Disk Boot Failure? |
|
Answer» I have a HP Desktop when turning power on it reads "Disk Boot Failure" |
|
| 8774. |
Solve : how to stop a command being run in a seperate dos window.? |
|
Answer» Good day everyone. Haven't been on here in AGES. i stopped making bat files but now |
|
| 8775. |
Solve : Need ErrorLevel/Exit Code Help.? |
|
Answer» Hi, I'm trying to create a batch file that will stop the xcopy and delete batch process and return an Error statement, in the event that there is not enough space on my destination drive or no files to copy or a physical disk error, etc ... or returns a successful copy message if there were no errors. This is what I have so far: 1. If the XCOPY is embedded in a FOR loop, the errorlevel is always zero but you can scrape the console for data. What about using delayed expansion and checking !errorlevel! ? Quote from: Salmon Trout on August 23, 2011, 12:02:13 AM What about using delayed expansion and checking !errorlevel! ? Been there, done that. Same results. See my previous post. Don't always succeed but try very hard to post only code that works. Anything else is left on the cutting room floor. The exclude file might create a problem with the VBScript CopyFolder method, but using Powershell to pipeline output from get-childitem into copy-item might work, depending on the actual exclude list.Thanks so much for your ongoing help! Again, unfortunately, the :nofiles and :success sections are working, but the batch still stalls when there isn't enough disk space on the destination drive (which should be Error 4, right?). This is what shows up in the batch's pop-up window: ---------------------------- Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: 22082011 _ (with this cursor blinking) ---------------------------- The batch does create the new folder (in this case, named "22082011), and copies over all the files that can fit onto the space left on the destination drive, but it doesn't then jump to the :copyerror section, and next copied over the 1KB .RTF file (which has a single line of text stating that nothing copied over because the drive was full), and then show in the batch's pop-up window the statement "The Archive Drive is FULL! STOPPING Backup Procedure." I again, tried deleting the .RTF file xcopy line in the :copyerror section, in the event that it might be the issue ... xcopy i:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT% ... but when I tested the batch again, it didn't make any difference; the batch still stalled with the aforementioned information showing on the batch's pop-up window: ---------------------------- Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: 21082011 _ (with this cursor blinking) ---------------------------- ... even though the batch did create the new folder and copied over all the files that can fit onto the space left on the destination drive. If the exclude file switch in the line: xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt I can always get rid of it -- xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y -- and have the .RTF error messages in the :diskerror and :diskcopy sections be copied from a folder on the destination h:\ drive, rather than the i:\ drive. like so: :diskerror xcopy h:\ErrorMssg\DiskError.rtf h:\archive\graphics\%INPUT% ... :copyerror xcopy h:\ErrorMssg\CopyError.rtf h:\archive\graphics\%INPUT% ... Or even eliminate those lines entirely; I just thought having a file stating that there was a problem with the copy process placed into the destination folder might be a good idea for purposes of record-keeping and archive integrity, but it doesn't need to be done, if it's causing problems with the execution of the batch file. ~ Sally Quote Again, unfortunately, the :nofiles and :success sections are working, but the batch still stalls when there isn't enough disk space on the destination drive (which should be Error 4, right?). This is what shows up in the batch's pop-up window: You can see for yourself what the actual errorlevel is by echoing it to the screen: Code: [Select]@echo off set INPUT= set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: md h:\archive\graphics\%INPUT% xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt > %temp%\results.txt echo %errorelevel% if errorlevel 5 goto diskerror if errorlevel 4 goto copyerror if errorlevel 2 goto copyterminated if exist %temp%\results.txt ( find /i "0 File(s)" %temp%\results.txt > nul if errorlevel 1 (goto success) else (goto nofiles) ) Also try leaving @echo on as the first line. The output may look messy but you'll get a good indication of how the batch file is executing. Code: [Select]The batch does create the new folder (in this case, named "22082011) Not related to XCOPY, there is a MD instruction to specifically create it. I guess what I'm not understanding why on errorlevel 4. you're copying a rtf file to a full disk and then knowing it will fail, echoing a message "The Archive Drive is FULL! STOPPING Backup Procedure.". XCOPY issues it's own messages based on the situation. Example: Errorlevel 4 also issues "Invalid drive specification" when the drive spec on the source or target paths is invalid. Perhaps you could check for errorlevel 1, which includes all errorlevels greater or equal to one and leave the default code (errorlevel 0) to distinguish between zero records copied and more than zero records copied. I checked my old DOS-5 manual and the XCOPY error codes have not changed in decades. It was my idea to have the .RTF file copied into the daily archive, in the event of some sort of copy error, since I am finding myself in the office less and less at the end of the day, and this task then falls to the office manager (who is the son of the boss, and is not detail-oriented, to say the least) or the OM's secretary/girlfriend (who is about as competent as Capt. Hazelwood on the Exxon Valdez) ... the problem being, that neither one writes down writes down error messages that might come up on their screens for anything they're doing, with any kind with any program, in any situation, which would then result in someone having to track down what had occurred, what caused the problem and how it could be fixed (if at all). I figured that with the .RTF file, we would at least have an explicit method with the daily archiving process of determining what error might have occurred, should there be any errors. It was also my idea in the first place to be using the batch file for the archiving, since prior to that, I had simply been doing the process manually, using copy/paste in Windows Explorer at the end of the day. But as this little start-up began to grow, and I began to be out of the office more and more, meeting with existing and new potential clients, the archiving task was then PASSED on to the OM and his Sec (much to their unhappiness), and there were a couple instances where they were placing the archived files in the wrong place or completely overwriting files, and it all turned into an incredible headache. So, I volunteered to come up with this automated batch process (with albeit very limited coding ability), in order to solve our daily archiving issue. It was only when our archive drive got filled up that I realized that I needed to have a batch that was much more sophisticated and specific than what I had initially created, and that I was (quite frankly) in over my head with what we needed the batch to accomplish. I tried adding in, after the xcopy line -- echo %errorelevel% -- but the batch didn't show any error codes and stalled onscreen at: ---------------------------- Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: 21082011 _ (with this cursor blinking) ---------------------------- Though the batch did create the new folder and copied over those files that would fit onto the space left on the destination (i.e., archive) drive. I also changed the first line to @echo on, but I didn't see any error codes, nor anything specific that would indicate where the problem was occurring. When I looked at the Results.txt file that was created in my Temp file, it also didn't show anything specific as to what might be causing the problem: ----------------------------- I:\Clients.xls I:\archive\graphics\Aer-Dgm.GIF I:\archive\graphics\NG.jpg I:\archive\graphics\Aquatics-logo.cdr {this is the file that is larger than the space left on the destination drive for the :copyerror test} Insufficient disk space on current disk. Insert another disk and type to continue... ---------------------------- When you say: "Perhaps you could check for errorlevel 1, which includes all errorlevels greater or equal to one and leave the default code (errorlevel 0) to distinguish between zero records copied and more than zero records copied." Do you mean changing the code to look like this?: ----------------------------------- @echo off set INPUT= set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: md h:\archive\graphics\%INPUT% xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt > %temp%\results.txt echo %errorelevel% if exist %temp%\results.txt ( find /i "0 File(s)" %temp%\results.txt > nul if errorlevel 1 (goto success) else (goto nofiles) ) ----------------------------------- Thus getting rid of errorlevel 5, 4, & 2? I guess that would work, except in the instance where there is a limited amount of space left on the archive drive, and during the archiving process only a limited number of files would get copied over; enough to fill up the remaining space, leaving the rest un-archived. But we need everything archived each day, and I can't count on the OM or Sec to be observant enough to notice that the archive drive is full, without a notice to that effect popping up on the screen. So, I guess I'm really at a quandry as to what to do. ~ SallyI was thinking more along these lines: Code: [Select]@echo off set INPUT= set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt 1>%temp%\results.txt 2>%temp%\results.log if errorlevel 1 goto :eof if exist %temp%\results.txt ( find /i "0 File(s)" %temp%\results.txt > nul if errorlevel 1 (goto success) else (goto nofiles) ) The first if errorlevel checks results from XCOPY; the second from the FIND command. results.log will contain any error messages issued by XCOPY results.txt will contain a log of the file copies along with the total number of files processed The two results files get overwritten each time the file is run. You can append each days output to the results files by using >> instead of > You can also change the paths of the results files. I chose %temp% hoping everyone has one. This should allow you to check the logs when convenient and not rely on someone else. Good luck. Correction to above post. Better to use findstr instead of find. A regular expression can better distinguish between an actual zero count and a count that ends in zero (10, 20, 100, 150 etc) Code: [Select]@echo off set INPUT= set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder: xcopy i:\*.* h:\archive\graphics\%INPUT% /D/E/R/I/K/-Y/exclude:i:\ErrorMssg\omit.txt 1>%temp%\results.txt 2>%temp%\results.log if errorlevel 1 goto :eof if exist %temp%\results.txt ( findstr /i /r "^0 files(0)" results.txt > nul if errorlevel 1 (goto success) else (goto nofiles) ) |
|
| 8776. |
Solve : Simple bat not working. Need some hints...? |
|
Answer» My ISP queues mail while my SMTP server is unavailable and unfortunately also sometimes queues it even while the SMTP server IS available. So, in order to dequeue the mail I run a finger command in a command window by typing: Code: [Select]finger [emailprotected] However when I do that and run it, the command window opens and the command is run very quickly over and over again until I close the window. You problem can be recreated if the batch file is named finger and you're logged into the same directory where finger.bat lives. If that is the case, simply RENAME your batch file. Just a thought. Sidewinder, that's brilliant! Your are a genius! I could not duplicate what he did. That explains it! The command interpreter always LOOKS in the current directory for a fie before looking into the PATH. That also explains why it was so quick. Finger can take a few seconds. But the command interpreter did do invoke the real finger executable, instead recursively called the bat file name 'finger'. Kind of like taking two mirrors and looking at your face...face...face...face...face.....I concur - sidewinder is indeed a genius. The file was in fact named Finger.bat (Doh!) so I renamed it to dequeue.bat and it works perfectly now. Thanks to Sidewinder and all those who PM'd me with suggestions. |
|
| 8777. |
Solve : Old computer boot up problem? |
|
Answer» A COUPLE of months ago I found a computer in the basement at work. The company was doing housekeeping and wanted to throw it out. I asked them if I could use it instead of throwing it out and they snickered because it was so old. Well I fired it up and it booted! It had DOS 5.0 on it and I had the perfect program for it to use at work. We needed a LABELING program to print out wire labels. I still had an old DOS label program on a floppy disk from the previous company I had worked for so I loaded it on the C drive. I wrote a batch file and the program loaded right up when I fired up the computer. We got super busy at work so the I sat the computer in the corner of shop as I was waiting for things to slow down a bit and I still needed a parallel printer cable to try it out. Fast forward a couple of months. When I boot up the computer now, I get three errors and no operating system. The errors are "bad or missing c:\dos\ansi.sys", "error in config.sys LINE 4", and "INCORRECT DOS version". I downloaded a DOS 5.0 bootable floppy disk from the internet that works fine on my home computer but says "non bootable disk" on the computer at work. I don't know if anyone on another shift messed with the computer or a least they won't fess up to it, but I am stuck. |
|
| 8778. |
Solve : how to open a folder? |
|
Answer» HI, is there a command to open a DIR in dos? for example, if i want to open the FOLDER fonts in dir c:/fonts i MEAN, to open it like double clicking. thanks.start "" "DIRECTORY name" thanks |
|
| 8779. |
Solve : Bucles for batch? |
|
Answer» I have this bat file : Not at the same time. When finish one continues with the next. START /WAIT BLA bla blaBut I need two groups How can I reference ? Quote from: Esgrimidor on April 09, 2011, 01:42:25 PM But I need two groups 2 batch files maybe... start "" "cmd /c batch1.bat" start "" "cmd /c batch2.bat" These will start togther but the commands in each one can run sequentially I'll try and comment. It's a good idea !!!!!!!!!!!!!!!!11 I have put FINALLY this : REM Autor Miguel Mollejo REM Archivo "diario_paralelo.bat" REM Este archivo ejecuta en serie las desfragmentaciones de todas las unidades de todos los discos. REM <--- Cambiar por la unidad donde este instalado MyDefrag. en la línea de abajo. Y: CD \ REM <--- Cambiar por la carpeta donde este instalado MyDefrag. REM No recuerdo cómo se ponía un comentario de un bat en una misma línea de comando..... CD "\PORTABLES\Utilidades Sistema\MyDefrag" start "" echo off rem no ejecuto la línea de abajo porque observo que no hace nada. Y añado al final del script la ejecución secuencial primeramente aportada por Miguel rem start "" "cmd /c batch1.bat" rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v C: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v D: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v F: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v H: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v I: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v K: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v M: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v N: start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v O: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v T: rem start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v X: start "" MYDEFRAG.EXE -r OptimizeDaily.MyD -v Y: MYDEFRAG.EXE -r OptimizeDaily.MyD -v C: MYDEFRAG.EXE -r OptimizeDaily.MyD -v D: MYDEFRAG.EXE -r OptimizeDaily.MyD -v F: MYDEFRAG.EXE -r OptimizeDaily.MyD -v H: MYDEFRAG.EXE -r OptimizeDaily.MyD -v I: MYDEFRAG.EXE -r OptimizeDaily.MyD -v K: MYDEFRAG.EXE -r OptimizeDaily.MyD -v M: MYDEFRAG.EXE -r OptimizeDaily.MyD -v N: pause "me quedo viendo lo sucedido" Best Regards Thank for everything. I'll try better next time |
|
| 8780. |
Solve : turn off windows automatic updates with batch? |
|
Answer» or use a wsus server that handles the deployment of security patches and the like. With wsus you can set the schedule of windows update and also control the patches that are displayed when new UPDATES are ready. This means the yellow shield that notifies you have updates only will display the updates APPROVED by the wsus admin. You can also set up different groups such as SERVERS, desktops, laptops, ext. |
|
| 8781. |
Solve : bat file to copy to an open folder? |
|
Answer» Hi, |
|
| 8782. |
Solve : move text from a notepad to the cmd? |
|
Answer» Is there a way to TAKE a text i WROTE in a text FILE and save it as a VARIABLE in the cmd. |
|
| 8783. |
Solve : extended keyboard character? |
|
Answer» When did DOS start using extended keyboard characters in the filenames, in ever?u mean the ones...like (æ)Yes that is ONE of them.Do you mean real MS-DOS or Windows? |
|
| 8784. |
Solve : Batch file in which is almost everything you need? |
|
Answer» Hey guys, Is this the sort of thing we really need on here? No. I would have though that trying to distribute trojan horses was something that ought to be frowned upon.This person has made (at the moment) one other post with the "offering". |
|
| 8785. |
Solve : Batch Command Logging? |
|
Answer» Hello, I'm trying to capture the output of my batch script to a log file for later review. I've found a way to capture the out put but I can't figure out how to get the batch script to then close or exit at the completion of the script.. I'm currently using 2 batch files to capture the log file which I will list below.. |
|
| 8786. |
Solve : Batch File Archive Extract/Move contents? |
|
Answer» Hello guys! |
|
| 8787. |
Solve : My Kingdom FOR a Loop!? |
|
Answer» Hello all, Seems somewhat absurd that there is no way to automate a batch file to run 100 times easily 1. MS-DOS is a operating system from the 1980s and 1990s. It hasn't really changed for 20 years. 2. You can do what you ask for with other tools such as QBasic, which was provided for this sort of thing. 3. You still have not said what OS version you are running. Quote When current civilization is long gone, anthropologists digging up the rubble find the only thing left intact is... QBASIC (clic here)Source: Anonymous |
|
| 8788. |
Solve : Error : loading boot sector? |
|
Answer» hello |
|
| 8789. |
Solve : Would someone recommend the CP/M OS?? |
|
Answer» I was speaking to my uncle yesterday, and he told me that MS-DOS was based off of the CP/M OS (Not the Emulator). It was released in 1976. I was speaking to my uncle yesterday, and he told me that MS-DOS was based off of the CP/M OS (Not the Emulator). It was released in 1976.Wait... what emulator? CP/M was Digital Research's Operating System, "Control Program for Microcomputers". QDOS was based on CP/M only as much as, say, Linux is based off of UNIX. Which is to say, not at all. It tries to seem similar to it's environment, but saying it was "based" off of CP/M implies that QDOS was actually based off of CP/M at the source code LEVEL, which it wasn't; Tim Patterson wrote QDOS because there was a need for it. Why all this talk of QDOS? QDOS was purchased by Microsoft, renamed to DOS, and licensed to IBM as part of their agreement. Quote Would someone recommend it, but not the Emulator to learn MS-DOS as for the OS?What? I'm going to say "no" here, although I'm not sure what you are asking. What Emulator? Either run it in a VIRTUAL Machine, or don't run it at all. As buggy and problematic as DOS itself is, CP/M raises that by quite a factor, particularly in regards to disk corruption. Most importantly, you aren't going to get CP/M working on a modern machine. A Boot disk, maybe. But have it boot from, say a partition of your hard disk? Very doubtful. Quote Would it be released as so many decades went by?No idea what you are asking. Quote Was it really based off of FAT8?No. CP/M does NOT use anything remotely compatible with the MS-DOS FAT file system. Quote Could I turn the floppy images into a bootable CD?I usually try to avoid speaking in absolutes but I'm going to say "No" here. Certainly not without some level of virtualization. In fact I doubt you could boot up CP/M on a modern system at all. Thank you for the info. I didn't mean to make you upset.Quote from: BC_Programmer on August 19, 2011, 10:27:37 AM have it boot from, say a partition of your hard disk? Very doubtful. Can be done, apparently, from the first volume of a CVV partition, and there are patches to get over the 8MB (!) partition size barrier. Quote I doubt you could boot up CP/M on a modern system at all. Of course CP/M-80 won't run on any x86 family processor, but CP/M-86 can be used on early type PCs with 8086 and 8088 cpus. Applying the unofficial "AT Patch" to CPM.SYS enables use with 286 and higher cpus, i.e. any AT-class machine (286, 386, 486, Pentium, etc.) There is another patch to enable dates after 1.1.2000 as well. Quote from: php111 on August 19, 2011, 10:48:48 AM Thank you for the info. I didn't mean to make you upset. Not sure what makes you think I was upset. Quote from: BC_Programmer on August 19, 2011, 10:54:15 AM Not sure what makes you think I was upset. Considering he's interested in CP/M, maybe he thought you'd got the "pip" as Bertie Wooster used to say. Thank you all for the info.Hey guys, I'm 29, and since I love the 80s way too much. I understand they didn't have PCs back then. They only had MS-DOS. Am I right or wrong? How, and what proper steps do I have to take to learn 80s DOS? Would it be the OS of MS-DOS 6.22?Quote from: php111 on August 19, 2011, 03:08:14 PM I understand they didn't have PCs back then.http://en.wikipedia.org/wiki/IBM_Personal_Computer Quote They only had MS-DOS. Am I right or wrong?You're wrong. I suspect you might be trolling. This very topic is about another OS choice that could be made at that time, so apparently that wasn't the only choice. Quote How, and what proper steps do I have to take to learn 80s DOS? Would it be the OS of MS-DOS 6.22?There is no "80's" DOS. and there would be no good reason beyond curiousity to learn EARLIER versions of MS-DOS (or CP/M, for that matter). 6.22 was released in 1992 or thereabouts, I believe. This type of stuff is pretty easy to google.Quote from: BC_Programmer on August 19, 2011, 03:15:16 PM http://en.wikipedia.org/wiki/IBM_Personal_Computer 1. I'm not trolling. 2. I'm really sorry that I want to learn an earlier version of DOS. Will you forgive me, please? 3. Do you want me to stop posting on this forum because of all of this?Quote from: php111 on August 19, 2011, 03:08:14 PM they didn't have PCs back then. They only had MS-DOS MS-DOS runs on PCs, and only PCs. What don't you understand about that? Quote How, and what proper steps do I have to take to learn 80s DOS? Read some BOOKS. Quote Would it be the OS of MS-DOS 6.22? Read some books. Then decide. Quote from: php111 on August 19, 2011, 03:32:34 PM 1. I'm not trolling. I have noticed that a lot of your posts fall into a kind of "stupid kid" category. It seems I am not the only one. |
|
| 8790. |
Solve : Parsing characters from a file name in batch? |
|
Answer» I need help. I could work at this for days but I know there are some DOS GURU's in here that can figure this out in minutes. the first file in a directory. Before I read your LATEST post, I had been thinking about this. About how you want to define the "first" file in a directory. I am guessing that you mean what you think is going to be the first file listed by a plain dir command ["plain" because it is without any /o (order) switches.] That is to say, the files sorted by NAME and in ascending order. In other words /on is implied. This is all very well, but there is an environment variable which can be present or absent in any PARTICULAR system called %dircmd% which sets default dir switches which are then used when just dir without switches is issued. e.g. it might be /od /a-d or whatever. If you are sure it is always going to be null, all well and good. Otherwise it is good practice and safer to specify. See dir /? for all the switches. Which BRINGS me to a way of avoiding the clumsy GOTO and the label. If you use dir /o-n then the sort is reversed so that the "first" file in order of name will be the last listed and therefore in your loop will be the last value held by %%a so you can just have a one line FOR statement. Code: [Select]for /f "tokens=2 delims=()" %%a in ('dir /b /o-n %targetdir%\*.tib') do set setnum=%%a Awesome Trout! That's even better! I'm an old COBOL programmer and never, ever left a loop so abruptly as a GOTO (unless absolutely necessary) but, I was at a loss and didn't know a graceful way out of the loop to preserve that 1st %setnum%. I never thought of a descending dir as you pointed out. I tested it and I'm putting that change in my routine now. I don't expect more than 8 files in the directory at any given time so the extra cycles are negligible to me. You are correct, my only concern IS the first file name in an ascending dir listing. One line of code to do all of this? Awesome. Thanks again! |
|
| 8791. |
Solve : From bat run another exe, then close bat? |
|
Answer» Hi, I am trying to run a exe program from a bat FILE, but the bat doesn't close until I close the exe program. Please help me as I have esimilar kind of query.Quote from: foxhunt99 on January 30, 2009, 03:32:10 PM Hi, I am trying to run a exe program from a bat file, but the bat doesn't close until I close the exe program.Code: [Select]@echo off start "" "D:\xyz.exe" |
|
| 8792. |
Solve : What are native DOS drivers for a LCD monitor?? |
|
Answer» Hey everyone, They need to be video drivers...for whatever card/chip you are running...not Monitor drivers. |
|
| 8793. |
Solve : Send message with CMD? |
|
Answer» I'm trying to SEND a message in CMD to a different computer, I know in XP the command is Really nice concept and question. If you do not know the answer, do not post. This is not a chat room. Then you must have an answer to it. Do you have any idea??? how can we do it.Quote from: vishuvishal on August 16, 2010, 12:23:48 PM
Please don't spam my post. Sometimes I just get so BORED... But I would be glad if someone knew if how/if you could do this.The bad news is : msg.exe is definitely not equivalent to net send. MSG is designed to send messages to 'sessions' on the same machine which is acting as a 'TERMINAL server'. To enable MSG to work without a Terminal Services session, you should activate the following registry key : HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server Name : AllowRemoteRPC Type : REG_DWORD Value : 1 Another solution is to use another lan messenger such as
But it is not free so ... let's try msg again ! So do Quote from: voluris on August 31, 2010, 03:32:08 AM HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server And I can send message? Btw is it only to Win7?msg.exe is not included with vista and windows 7 home (basic or premium) editions. So unless you have an office or enterprise EDITION (?), you're out of luck with that command.Quote from: MattPwns on September 02, 2010, 04:56:12 AM msg.exe is not included with vista and windows 7 home (basic or premium) editions. So unless you have an office or enterprise edition (?), you're out of luck with that command. I have the Ultimate edition and I do think I got the msg.exe, but still is only for LAN, and I have been trying to get it to work with a VPN program but didn't GO so great. But even if I got it to work in a VPN program both of the computers need to start it, and it's that what I don't want, I just want to send a message without a 3'rd party program. To be able to receive a message through a VPN (or to a host computer for that part) you must do; Code: [Select]HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server Name : AllowRemoteRPC Type : REG_DWORD Value : 1 (the dafault is '0') So it seems like you can't send a message in Win7 by the msg to a other IP address, but can you get the net send back to Win7? |
|
| 8794. |
Solve : MS-DOS files to covert to Windows 7? |
|
Answer» I have a few floppies filled with files created in the early 1990s in MS-WORD for DOS 5.0. I still have the "style sheet" files used to create margins, etc., but the important thing is simply to be able to access the text in the DOS files Is there a way to convert them to Windows 7 files that I can access on my new computer?It sounds like you are asking two or three questions. 1. Current versions of MS-Wed can read the older files of Word. 1. Microsoft doesn't seem to provide conversion filters for Word 5 in later versions of Word ("MS-Wed" ). There are two approaches I can think of, however. See below. 2. As long as the floppy is still capable of being read. (a) You can download a file converter from Microsoft. If you search the Microsoft Knowledge Base, you won't find any information about doing conversions from Word 5. An older converter is still available, however, if you know where to look. The converter name is WDSUPCNV.EXE, and it is available at this Microsoft FTP site: ftp://ftp.microsoft.com/softlib/mslfiles/wdsupcnv.exe This works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003. INSTRUCTIONS for use here: http://word.tips.net/T000791_Converting_Word_for_DOS_Documents.html I imagine some kind of bulk conversion would be most desirable, though. (b) You can legally download Word 5 for MS-DOS free from Microsoft and load the files and then save them as RTF or plain text. This requires a system that can run 16-bit MS-DOS PROGRAMS. In 1999 MS released a Year 2000 compliant version of Word 5 and just decided to give it away for free. Beware that the RTF standard has changed somwhat in 20 years so some less mainstream features may not export correctly. The installer is downloaded from here: http://download.microsoft.com/download/word97win/Wd55_be/97/WIN98/EN-US/Wd55_ben.exe Personally I would get those files off those 20 year old floppies straight away. If they are important to you, that is. Perhaps you could buy some archive quality CD-ROM blanks and burn them. I PRESUME you have checked that the floppies are still readable? Salmon Trout is amazing. His answer is much better than mine. (But he has such a fishy name.) |
|
| 8795. |
Solve : Format cannot run because in use by another process. Are my commands right?? |
|
Answer» I am trying to format, and write zeros on my sectors. I know it's time consuming. I just want to do it. If you are booting to the CD select remove partition and recreate. Unless the FBI is looking for you ... :L This is a way of writing 0's to the drive if you so desire it ... http://pcsupport.about.com/od/toolsofthetrade/ht/write-zeros-format-command.htm But as said above ... ALL data will be erased and drive may be made unusable.I personally rather to use DBAN (Darik's Boot and Nuke). It's DoD certified. Or KillDisk does the job as well. Just set DBAN for the Gutmann Wipe. That's what I'm doing at the MOMENT. That's my opinion. It does a better job then the COMMANDS I gave. Quote from: Geek-9pm on August 17, 2011, 08:33:50 PM The C: drive is the boot drive. Low leveler formatting is a out-of-date term. Users don't low level format anymore.You are MAKING it alot harder than it is...Another thread - http://forums.techguy.org/general-security/1013046-what-does-everyone-recommend-wiping.html |
|
| 8796. |
Solve : RNS MS-DOS? |
|
Answer» Hi everyone! He gave me a MS-DOS program and asked me how it can be run on windows 7. 1. Why won't you tell us its name? 2. You may be able to use an emulator such as DOSbox. |
|
| 8797. |
Solve : Unattended SQL Express 2008 R2 Install on Windows 7? |
|
Answer» I am trying to run a batch script to do an unattended install of SQL Express 2008 R2 with Advanced SERVICES on a Windows 7 SYSTEM. The script I wrote based on the MSDN articles I found is as follows: |
|
| 8798. |
Solve : set command doesn't work with if as it says on the explanation? |
|
Answer» In the explanation of the set command in the cmd it says to write a program like this: it doesn't recognize the value of the !var! , why is that? TRY reading the entire help blurb, especially the part about delayed environment variable expansion. Quote from: kyou8 on April 26, 2011, 04:32:32 AM another question, can i set a permanent variable that won't disapear after i close cmd, like windir,cd,errorlevel and such... Not thru batch code. You can USE any Windows Script language or use the GUI by RIGHT clicking on My Computer==>Properties==>Advanced==>Environmental Variables. By the way, cd, errorlevel, and such are context DRIVEN and do not have permanent values. Windir was set when the OS was installed, why do you want to change it? Quote from: kyou8 on April 26, 2011, 04:32:32 AM another question, can i set a permanent variable that won't disapear after i close cmd yes, use SETX. |
|
| 8799. |
Solve : future time saving? |
|
Answer» Hello, Just noticed that a question about time arithmetic was first responded to by a poster name TimeKeeper. What are the odds? Considering that was really Billrich, who needs to craft a new fake name every time he posts, this is not much of a coincidence. |
|
| 8800. |
Solve : editing dos when no hard drive is used? |
|
Answer» I am running a GAME that is dos based. No hard drive. Only a cdrom used.Dos 6.2. The boot info is on the cd. I need to EDIT something in the config.sys but cant get to it. At dos promt, is says its located in a:\ dir. cd is located in c:\. I assume the a: is the ram drive and the info is located on the ram. |
|