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.
| 1751. |
Solve : move each file to a separate folder? |
|
Answer» hi The process cannot access the file because it is being used by another process. i even restart my system but nothing has changed i can identify and move all of these files with other batch files so what's wrong? Quote from: mioo_sara on May 30, 2009, 05:27:05 AM thanks dear devcom for your fast replyFirst off, files that are being used by another process or computer can't be modified or moved until whatever else is using them has stopped. Code: [Select]echo off setlocal enabledelayedexpansion for /f "tokens=*" %%A in ('dir /b *.exe') do ( set fileName=%%~nA md "!fileName!" taskkill /F /IM "%%A" echo move "%%A" "!fileName!\setup.exe" ) pause try now if this will work REMOVE echo from 8 line Quote First off, files that are being used by another process or computer can't be modified or moved until whatever else is using them has stopped. so why i can move them with below SCRIPT? Quote echo off & setLocal EnableDelayedExpansionwow !! it worked devcom thanks my man although i saw error message for all files but this time all the folders have created and they are all renamed and exe files are moved and renamed wonderful now dear devcom if its ok with you can you help me with this 2 last request? question 1= there are some more files (.com and .txt) files in this folder next to the others (exe file) now i wnat them to be moved to one folder (each one) so how can we change above script? i changed Quote for /f "tokens=*" %%A in ('dir /b *.exe') do ( so is there any problem with that? so what about this line? echo move "%%A" "!fileName!\setup.exe" this command rename all file to setup.exe so what can i do for .txt and .com files? txt file should be rename to readme.txt .com files should be rename to setup.com question 2= some of files have "update" or "uninstall" word in their names these kind of files should be renamed to update or uninstall (ignore to rename them to setup) thanks my dear devcombut you want to do this the same way as .exe for .txt and c.om ? so you have file test1234.txt and you want to make test1234 folder and put the .txt file there as readme.txt ?sorry dear devcom for answering late yes i want the exact of operation that you mentioned thanks i am waiting Code: [Select]echo off setlocal enabledelayedexpansion for /f "tokens=*" %%A in ('dir /b *.exe *.txt *.com') do ( md "!fileName!" 2>nul set fileName=%%~nA ::set fileName=!fileName:update=! ::set fileName=!fileName:uninstall=! set fileExt=%%~xA if "!fileExt!" equ ".txt" (set moveName=readme) ELSE (set moveName=setup) call :FIND "%%A" echo move "%%A" "!fileName!\!moveName!!fileExt! ) pause exit :FIND set find=%~1 echo.%find% |findstr /I "uninstall" >nul && set moveName=Uninstall echo.%find% |findstr /I "update" >nul && set moveName=Update exit /b this should work PS you can remove :: from 8,9 line to make folders without update or uninstall word ,i mean if you have file: 'test update.exe' it will create 'test' folder instead of 'test update' folder if you delate :: PS.2 ofc you need to remove echo if this will workWhy does "Mioo_Sara" want to move ".exe" files into separate unique folder? What is the goal of such a strange movement of .exe files? What is Mioo_sara trying to accomplish? Quote from: mioo_sara on May 30, 2009, 03:45:59 AM himaybe he created 1000 apps and now he want to clean his computer ? Quote from: devcom on May 30, 2009, 03:51:10 PM maybe he created 1000 apps and now he want to clean his computer ? If clean the computer of .exe files, then del is better than move. The movement of .exe to a unique folder was not restricted to .exe files created by the user. It is and was a nonsense and dangerous exercise to move .exe files to a unique folder.billrich is right, this is odd. |
|
| 1752. |
Solve : Evil batch? |
|
Answer» I have a batch that I made so when I exit my money that in case I FORGOT to back-up to a floppy, which save me a good many to put a copy of it on there. When I run it however it comes up saving that there isnt enough room on the disk. If I do it in the program there isnt any issues but its a pain to go back an put in all the REQUIRED info.Not enough room on the floppy?LOL Hypocrite. In general, I have found that, when the error issued is "Insufficient disk space" or something similar, it is a good idea to check the free space on the target drive. I never said there might be something wrong with the floppies.Maybe whatever you're trying to copy is too BIG for the floppy?woah, slow down there Carbon- He's supposed to FIGURE that out himself! I didn't want this topic to carry on for another 5 pages. |
|
| 1753. |
Solve : Delete files - older than 7 days? |
|
Answer» I have a folder where every day backup files are copied from a system. |
|
| 1754. |
Solve : WINRAR - FILES? |
|
Answer» I am taking CERTAIN types of files as backup into a particular folder every day using the FOLLOWING batch files. |
|
| 1755. |
Solve : I am really need a help please? |
|
Answer» I am really need a help please I am really need a help pleaseOk...I don't think you can make a user log in, as I'm fairly sure that batch files get executed after they log in...but, you COULD do this. echo off set log=Shared folder path\log.txt for /f "tokens=1-2 delims=: " %%A in ("%time%") do set tme=%%A^:%%B echo %username% has logged in at %tme%. >> "%log%" exit And one to check to see if he logged in, echo off :loop cls type "Shared folder path\log.txt" ping localhost -n 2 > nul goto loop If you put the first one in the startup script, you will always know when someone logs in. |
|
| 1756. |
Solve : write batch programming with html if possible ??? |
|
Answer» hi want to use batch programming in HTML home page like we use javascript. if possible please be more clear. If you want to do web programming, get a web programming language, PHP, Python, Perl, RUBY ETC I agree with gh0std0g74 .... and the only integration with HTML and Batch would be links to batches for execution or download, and that is DANGEROUS for visitors if your batches are malicious. In IE you also would see a security warning. I ran into this problem when before learning Visual C++ wanted a nice INTERFACE for my console app programs. Security Blat was annoying so I just learned how to make GUI apps instead the right way vs a mix of compiled C++ and HTML GUI interface. |
|
| 1757. |
Solve : Using a .vbs file to launch a batch file? |
|
Answer» I WOULD like to launch an application using a batch file. I have no problem doing this: |
|
| 1758. |
Solve : batch file that read from a txt file line by line? |
|
Answer» Hi All |
|
| 1759. |
Solve : how put a file list into a variable (string)? |
|
Answer» Hi All: |
|
| 1760. |
Solve : Download file trough batch? |
|
Answer» Hi there, wait a minute- ever since VB moved from 16-bit to 32-bit and dumped HLSTR's in favour of BSTR's it has had a maximum string size of 2GB... Thank you for your responses. After looking a long time i have found the following script which works perfectly, but I only have one problem. It promps with an useless textbox to say where the file is saved. This ins't really user-friendly because the user doesn't need to be BOTHERED which such information imo. Does anyone now how to avoid the message box? Thanks in advance script: End Function you can use wget too Quote from: devcom on June 02, 2009, 02:58:10 PM you can use wget too except: Quote P.S. Installing external command line tools isn't an option, cause I can't install anything else |
|
| 1761. |
Solve : copying and renaming files? |
|
Answer» There are files of the form Volume in drive C is OShere's a vbscript Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) mth = Month(Now) d = Day(Now) If LEN(mth) <2 Then mth="0"&mth End If If Len(d) < 2 Then d = "0"&d End If i=mth&d For Each strFile In objFolder.Files strFileName = strFile.Name If InStr(strFileName,"a-hire") > 0 Then BaseName = objFS.GetBaseName(strFileName) Extension = objFS.GetExtensionName(strFileName) NewName = BaseName & "-" & i & "." & Extension strFile.Name = NewName End If Next |
|
| 1762. |
Solve : Ouput cannot be redirected to a file or a program? |
|
Answer» Hi, |
|
| 1763. |
Solve : Pen Drive Is not accessing? |
|
Answer» Hello friends i am not able to open my PEN drive through mouse,it says"access denied"... |
|
| 1764. |
Solve : Creating a current date directory then moving files to the directory? |
|
Answer» I have syntax to create a current date directory yet not sure how to move text files within the newly created directory. del file.txt 2>error.txtSorry for sounding dumb but what does file.txt represent? Delete file.txt produces error.txt? Why the delete? Quote from: JTS on June 03, 2009, 10:42:58 AM Sorry for sounding dumb but what does file.txt represent?Dev just used delete as an example...if you used mkdir Foldername 2>error.txt, it would echo any errors to error.txtThanks all for the help....appreciate it.. |
|
| 1765. |
Solve : How To play Music? |
|
Answer» can ANYONE TELL me how can I PLAY mpg file using DOS command? |
|
| 1766. |
Solve : Mass Copy? |
|
Answer» It has been a long time SINCE I have used DOS, |
|
| 1767. |
Solve : Copy from current path?? |
|
Answer» Hello everyone. I am trying to include some lines in a bat that will copy files from the current location to a specified path on a drive. Hello everyone. I am trying to include some lines in a bat that will copy files from the current location to a specified path on a drive.First off, you need to do a bit of registry modding for that script to work on a computer...LNK files are hidden, and you can only unhide them by deleting a certain registry. Batch can't see them unless you do it... If you want to move files which are in the current directory, just use their names and EXTENSIONS.Oh...wow i feel like a newb again. I knew there was a registry bit, but i ran that on my PC a while back. Or are you referring to running the registry change on the server? i chaged the path to just the filename and extension and tried running the bat and the following is what i get. Quote '\\server\infotech\test'Quote from: TheHoFL on June 02, 2009, 04:32:35 PM Oh...wow i feel like a newb again. I knew there was a registry bit, but i ran that on my PC a while back. Or are you referring to running the registry change on the server?On any computer that the batch file will be run on, the registry changes must be made.Okay, got it working. Below is my code that adds the registry that will allow running a bat from a UNC path. It worked perfectly. After running a BAT with the "REG" line should allow you to run any BAT from a UNC path. Code: [Select]Echo off REG ADD "HKCU\Software\Microsoft\Command Processor" /V DisableUNCCheck /T REG_DWORD /F /D 1 SET THISDIR=%~dp0 copy /Y "%THISDIR%Mitchell1.lnk" "%ALLUSERPROFILE%\desktop" copy /Y "%THISDIR%Gradebook.lnk" "%ALLUSERPROFILE%\desktop" echo The new files have been copied. pause Echo on Quote from: TheHoFL on June 02, 2009, 05:05:46 PM Okay, got it working. Below is my code that adds the registry that will allow running a bat from a UNC path. It worked perfectly. After running a BAT with the "REG" line should allow you to run any BAT from a UNC path.Ok... Two things. 1. Any computers that runit must have all instances of NeverShowEXT or they will get a file not found error...(Just so you know) 2. Why do you turn echo on at the end?Yeah i know. Only IT will be using this and we have our PCs setup CORRECTLY to use it. Thanks for the info though. Quote from: TheHoFL on June 02, 2009, 05:18:57 PM Yeah i know. Only IT will be using this and we have our PCs setup correctly to use it. Thanks for the info though.Ok and No problem! Quote First off, you need to do a bit of registry modding for that script to work on a computer...LNK files are hidden, and you can only unhide them by deleting a certain registry. Batch can't see them unless you do it... Not true... I can see LNK files in cmd with all my PCs. NeverShowExt applies to EXPLORER, not cmd. Same with the other "show hidden files", show extensions for known filetypes, etc etc. "LNK" files aren't "hidden" per se, but rather special shell files. usually around 400 to 600 bytes. Really, they evolved as a windows version of the older "PIF" files from windows 3.0/3.1. see here: HKEY_CLASSES_ROOT\.lnk aside from the keys here, refer also to: HKEY_CLASSES_ROOT\lnkfile which has the "NeverShowExt" option you mention. (which applies to explorer, and other applications which respect the option) I have it present, and I can see LNK files with dir. "editflags" sets the option so that the folder options dialog will not show LNK in the file associations list. (imagine the havoc if that association was accidentally deleted!) Which brings up an interesting point- there isn't really an association to anything for a shortcut- but rather an association to a particular Shell object, Likely a Shell interface object. My guess would be that the shell instantiates the object and de-serializes it's state from the shortcut's contents, and then the shell uses it's IFolderItem Interface to perform file-like tasks (most likely, execution) that in general operate on the target rather then the shortcut. However- anything to do with file associations is irrelevant when speaking of DIR or the command processor- it doesn't respect anything of the sort, and simply displays the files that are present. |
|
| 1768. |
Solve : how to open banned orkut? |
|
Answer» in my clg ORKUT is banned is there any proxysite by which i can open it?i tried some of them but they have'nt worked.Read the rules Filters on school computers and in the WORKPLACE are there for a reason. If they don't WANT you to do certain things on their network, it is your obligation to respect that. We do not assist in bypassing these filters. If you feel that you have a good reason, you need to discuss it with the network's administrator. |
|
| 1769. |
Solve : How do I remove " from a varable?? |
|
Answer» I have a variable: |
|
| 1770. |
Solve : Command prompt stopped recognising commands!? |
|
Answer» I felt like making a ping to my router, when for no apparant reason it didnt recognise the command. |
|
| 1771. |
Solve : Can someone tell me how to stop a batch file?? |
|
Answer» I ran this program: |
|
| 1772. |
Solve : random?? |
|
Answer» hi is there a peice of code that will pick a variable from a list out at randomYes...by picking out from array but random will only follow algorithm UNLESS you seed it. Random will always pick say 3,4,7,5,2 in that order if executed again and again after closing it unless you add a seed to influence the algorithms output in which the output is less likely to be guessed in the order at which it will spit out the outcome. Example for choosing a random # from 0 to 10:Really? I always have to use goto loop so I can get a number...but depending on the number, can take a fairly long time. Code: [Select]set /a return=%RANDOM%%10 that will only generate a rand number. imagine a list of numbers eg 10,20,30,40,50. you will need to get a random item out of this list, not by simply using the above code. Quote from: gh0std0g74 on June 16, 2009, 06:43:00 PM Code: [Select]set /a return=%RANDOM%%10Well, most more advanced needs require more lines in a script. echo off :loop set /a rnd=%random%%50 if %rnd% neq 50 if %rnd% neq 40 if %rnd% neq 30 if %rnd% neq 20 if %rnd% 10 goto loop echo The random number is either 10, 20, 30, 40 or 50. echo Your random number is %rnd%. pause > nul Quote from: Helpmeh on June 17, 2009, 04:05:23 PM Well, most more advanced needs require more lines in a script.not really. if %RANDOM% doesn't hit a number in the list forever, are you going to wait forever?? use the number of items on the list with %RANDOM% instead. Quote from: gh0std0g74 on June 17, 2009, 06:08:30 PM not really. if %RANDOM% doesn't hit a number in the list forever, are you going to wait forever?? :-Xuse the number of items on the list with %RANDOM% instead.I personally have never used the %random%%10 style, but the 10, 20, 30, 40, 50 numbers was just an example. For your example getting a random choice of a certain list, this would work. It would also work as a much quicker version than my previous code. echo off set /a rnd=%random%%5 set /a rnd*=10 echo %rnd% pause>nul Quote from: Helpmeh on June 17, 2009, 06:48:32 PM I personally have never used the %random%%10 style, but the 10, 20, 30, 40, 50 numbers was just an example.and if the list of numbers is 1,2,3,4,11,13,16 for example, your code will not work isn't it? what i am saying , 1,2,3,4,11,13,16 has 7 items. generate a random number from 1 to 7, (not the max value of the item ie 16). If the random number is 5, then use a loop or something, go through the list to position 5 and get the number "11"Yeah, I was just taking advantage of the consecutive numbers. echo off set /a rnd=%random%%7 if %rnd%==5 set rnd=11 if %rnd%==6 set rnd=13 if %rnd%==7 set rnd=16 echo %rnd% pause > nul would do the trick for your example. Quote from: Helpmeh on June 17, 2009, 07:38:03 PM would do the trick for your example.not enough. try not to hard code those numbers. Quote from: gh0std0g74 on June 17, 2009, 07:54:59 PM not enough. try not to hard code those numbers.I'm SLIGHTLY confused now...you want them set as variables? echo off set var1=1 set var2=99 set var3=1234 set var4=12 set var5=6 set /a rnd=%random%%5 set varout=%var%%rnd% echo %varout% pause>nul Hope that works!I can't believe anybody would use a loop to generate random numbers over and over... ever. Even the case, where there is one index that is unused (IE, 5) can be RESOLVED without the need to resort to a looping mechanism. For example: Code: [Select]1,2,3,4,11,13,16 the easiest way, as ghostdog said, is essentially to index the values. Code: [Select]Sub Test() Dim arrayTest as Variant Dim resultrnd as Long ArrayTest = Array(1,2,3,4,11,13,16) resultrnd = ArrayTest(Rnd*Ubound(arraytest)+Lbound(arraytest)) End Sub if you had a disjoint array somehow, simply inspect the returned random number; add a number equal to the amount of "nil" space that it is above. |
|
| 1773. |
Solve : copy to multiple computers...but differently?? |
|
Answer» I know how to copy files to multiple computers, but i am curious if i can have files copied to multiple computer in a better way...maybe have the BAT file pull the computer names from a list or something, so the BAT file is a bit more easily read for other co-worker that MAY not work with BATs that ofthen. Server Name Remark |
|
| 1774. |
Solve : xcopy no prompt? |
|
Answer» I'm doing a copy with the following command to perform a copy. |
|
| 1775. |
Solve : HELP!! Converting xml file to csv using batch file? |
|
Answer» Hi, |
|
| 1776. |
Solve : put limitation for avoid accessing to some steps? |
|
Answer» hi echo off but i need to put some limitation in some of steps in following way i want if some files has found (php,ini,txt ) just step 1and 3 should be accessible and then go to end but if (xml,dll,exe)files has found all steps should be accessible is there any idea? sorry guys : if it's possible read my next post in this topic to find out more information C:\>type findfiles.bat Code: [Select]echo off setLocal EnableDelayedExpansion echo. > txtphpini.txt dir /s /b *.txt *.php *.ini >> txtphpini.txt echo. > xmldllxe.txt dir /s /b *.xml *.dll *.exe >> xmldllxe.txtC:\> findfiles.bat Quote from: billrich on June 19, 2009, 02:55:58 PM C:\>type findfiles.batThat might not exactly help the OP out, depending on their knowledge level... But in conjunction with your SCRIPT, echo off for /f "delims=" %%A in ('type txtphpini.txt') do ( REM YOUR COMMANDS HERE REM USE %%A AS A FILE NAME REM DON'T REMOVE THE BRACKETS REM THIS DOES NOT NEED TO BE REMOVED ) for /f "delims=" %%B in ('type xmldllxe.txt') do ( REM YOUR COMMANDS HERE REM USE %%B AS A FILE NAME REM DON'T REMOVE THE BRACKETS! REM THIS DOES NOT NEED TO BE REMOVED ) Will work just fine. Insert the commands for the txt, php & ini files, then copy those commands to the xml, dll & exe section, then add the xml, dll & exe only commands too.Helpme, With all due respect, Your code is much more difficult for mioo_sara to understand than my code. By the way, my code created the "xmldllxe.txt" file and the txtphpini.txt file . Mioo_sara, the original poster, offered no file names. Quote from: Helpmeh on June 19, 2009, 04:54:59 PM Quote from: billrich on June 19, 2009, 05:09:36 PM Helpme,I'm not saying my code is better or easier than your code. I'm saying that in combonation with both of our codes, the OP can actually use the directory your code makes to do work. For example, if txtphpini.txt contained this: C:\Test\test.txt C:\Blah\test.php C:\NONE\test.ini then this code could delete them. for /f "delims=" %%A in ('type txtphpini.txt') do ( del %%A ) This reminds me of what my scout leader used to say..."Apart, you can't do anything usefull with those talents, but together you can do anything!"Helpme, Yes, two heads working on a problem usually find a solution quicker. But, I don't understand what Mioo_sara is after. Mioo_sara needs to find files with certain EXTENTIONS: exe, ini . . . . Many of the files are important system files and surely Mioo_sara's goal is not to delete system files or to move system files from their original FOLDER? We really don't have enough information to define the problem. My code did not create any new directories (folders ). My code created two new files and placed the files in the root ( C:\ ) directory. Quote from: billrich on June 19, 2009, 05:37:25 PM Helpme,Billrich, Here's what I can see the OP wants: The OP has a set of commands, some of which should only be run on txt, php or ini files, and all of them run on xml, dll or exe files. Here's what I can see you've done: Created a batch script that CREATES a directory of all the txt, php and ini files in one text document, and xml, dll and exe files in another. Here's what I can see I've done: Used the two directory files in for loops so multiple commands can be performed on each file automatically. Here's what I see we've done together: Completed what the OP wants.i'm back again thanks dear (billrich and Helpmeh) for your replies and your scripts Quote Here's what I can see the OP wants: yes helpmeh you got me ! this is what exactly i need but i think you and billrich just focus on files and not commands and steps in my real program there is more than 100 lines of codes and there is lots of for example %%A so i think i should put my pressure on something more unique attention= 1- in real program there is more than 15 step that contain different commands 2- files should not follow all commands and steps (one by one ) so .... 3-as you can see in next example some commands are in separated steps and they are acondylose 3- in below example for (php,ini,txt ) files , they should go through lots of commands not just 1 and 2 example= for (php,ini,txt ) files these are the steps that (php,ini,txt )files should go through Quote :step1 it is more similar to what i want ==================================================== Mioo_sara, Please post your one hundred lines of code. C:\>sort txtphpini.txt | More C:\1100\SETUP.INI C:\a-hire.txt C:\aaa.txt C:\bat.txt C:\batextra\bill72.txt C:\batextra\caavsetupLog.txt C:\batextra\caisslog.txt C:\batextra\christmas.txt C:\batextra\count.txt C:\batextra\data06.txt C:\batextra\date.txt C:\batextra\db.txt C:\batextra\disklog.txt C:\batextra\file.txt C:\batextra\for.txt C:\batextra\hist.txt C:\batextra\homewk.txt C:\batextra\Instruct_for.txt C:\batextra\list_of_program_files.txt C:\batextra\listone.txt C:\batextra\log.txt C:\batextra\noperiod.txt C:\batextra\outmenu.txt C:\batextra\period.txt C:\batextra\pipe.txt C:\batextra\session.txt C:\batextra\show.txt C:\batextra\signal.txt C:\batextra\str3.txt C:\batextra\task.txt C:\batextra\temp1.txt C:\batextra\test07.txt C:\batextra\testfilnam.txt C:\batextra\tips.txt C:\batextra\win.ini C:\batextra\x.txt C:\batextra\xmas.txt C:\batextra\xxx.txt thanks billrich well i created a program with adobe flash for my weblog inside there is lots of codes(action scripts codes) but because flash can not work with outside world easily !! i have to use third party tools . so i choosed batch codes because they are easy to understand and easy to work with now i have more than 20 bat file (i put all of them inside of my program and with pressing each button when we need they create in temp folder and get start) but problem is here that i want to put all these batch codes in a single bat file and call every command from inside of it i dont know if it's possible or what? well if i put each particular code in a separate bat file they will work very nice but is there any possibility to start a batch file and call commands from inside of batch file when we need it? Mioo_sara, Where is the code? Post the code. You may put all the code in one batch file. or You may call each of the batch files from one central batch file. Where is the code? Post the code. ok i will put all codes in a batch file and send it to you |
|
| 1777. |
Solve : Detect time in batch file? |
|
Answer» i need my batch file detect time.... Easy... helpmeh, theres one flaw in the script Quote for /f "tokens=2 delims=: " %%a in ("%time%") do if %%a%%b gtr 1645 (goto shut) else (goto start) tokens should equal 1-2 because it will only turn out as: (minutes)%%btotally missed that...writing on a dsi is hard.psp isn't a walk in the PARK either Quote from: BatchFileBasics on June 14, 2009, 11:30:16 AM psp isn't a walk in the park eitherToo true...although DSi Internet uses the touch screen for typing, loading the keyboard takes a lot of time, as does everything...it also has a 700 something by 800 something resolution...and it uses opera, which I have never used previously.yea. i am using opera right now. very fast to start up cold and all. its pretty fast too. doesn't burn your CPU down(well mine anyway). Quote from: BatchFileBasics on June 14, 2009, 12:09:55 PM yea.Other than opening the keyboard, it's fairly fast...yea, and seeing from other posts, you really love telling people. Quote that should do it...I had to MAKE that on my dsi so I had to write everything, no copypasta. Quote btw, I can't test it as I am STILL on my DSi Quote from: BatchFileBasics on June 14, 2009, 12:28:32 PM yea,I'm excited is all...I got it for my confirmation (along with $250), so I've been GOING crazy!i know how you feel. when i first got my psp. myspace was so fun haha. "hey whats up, i just got my psp and im writing right now!!!!" "hey guys guess what, im writing on my psp" hahaI see you guys are working hard on Fareast187's problem. |
|
| 1778. |
Solve : Custom Screen Saver Issues? |
|
Answer» Hello everyone! |
|
| 1779. |
Solve : logon.bat help - resources if in specific groups? |
|
Answer» Hello again! |
|
| 1780. |
Solve : In need of a batch file HELP!!!!? |
|
Answer» Im sorry...totally new to the forum. We are supposed to get new files from a vendor daily Will all files be in the same folder? Will all files have the same extension? What is your date format? Please read this. Quote from: Dusty on June 17, 2009, 03:37:30 PM Welcome to the CH forums. Files will ALWAYS be in same folder.... always .txt extension and date format is month/day/year (4 digit year) Windows.. I apologize for not being more thorough. Thanks. MThis script is totally untested... It hopefully will check for a filedate of yesterday and today so that if the date today is the 20th it will check a filedate of 19th and 20th. If you want to check for 18th 19th and 20th CHANGE the echo otherdate = (Date(^)-1^) command line to echo otherdate = (Date(^)-2^) Code: [Select]echo off cls setlocal set newfile=%temp%newfile.vbs ( echo otherdate = (Date(^)-1^) echo yy = datePart("yyyy", otherdate^) echo mm = datePart("m" , otherdate^) echo dd = datePart("d" , otherdate^) echo wscript.echo yy^&" "^&mm^&" "^&dd )>>%newfile% FOR /F "tokens=1-3" %%A in ('cscript //nologo %newfile%') do ( set year=%%A set month=%%B set day=%%C ) del %newfile% if %month% lss 10 set month=0%month% if %day% lss 10 set day=0%day% set today=%year%%month%%day%% for /f "delims=" %%1 in ('dir /b "path\filename.txt"') do ( set filename=%%1 set filedate=%%~t1 ) set filedate1=%filedate:~6,4%%filedate:~3,2%%filedate:~0,2% if %filedate1% geq %today% echo %filename% date/time is %filedate% & exit /b echo %filename% date/time %filedate%is not within 2 days of today's date. & exit /b Good luck. Edit: changed script in response to Ghostdog74's post below. Quote from: Dusty on June 17, 2009, 05:17:45 PM If you want to check for 18th 19th and 20th change the set /a command line to set /a today=%today%-2i am sure you know you can't simply minus a date like this in batch? extra code is needed to check dates for eg if date is 01 Jun and 02 Jun, then 2 days before is 30, 31 may.... Quote from: mattf2171 on June 17, 2009, 03:41:47 PM Files will ALWAYS be in same folder.... always .txt extension and date format is month/day/year (4 digit year) Windows..NOTE windows file names cannot have "/". assuming you can download GNU coreutils (SEE my sig) you can use GNU date Code: [Select]echo off for /f "tokens=*" %%a in ('date_gnu "+%%m/%%d/%%Y" -d yesterday') do ( set yest=%%a) for /f "tokens=*" %%a in ('date_gnu "+%%m/%%d/%%Y" -d "2 days ago"') do ( set twodaysago=%%a) echo %yest% %twodaysago% output Code: [Select]C:\test>test.bat 06/17/2009 06/16/2009 use the if/else to compare your dates. Quote from: ghostdog74 i am sure you know you can't simply minus a date like this in batch? OMG how could I have made such an enormous fup? Thanks for your timely reminder. Should have switched on brain when getting out of bed. D.I am working on modifying the script to suit my situation. Thanks to all who have responded. Its a great help. I will post back with results. M |
|
| 1781. |
Solve : Creating an Hex file using a Batch file? |
|
Answer» Hi all, |
|
| 1782. |
Solve : renaming file extensions? |
|
Answer» i'm trying to RENAME a file extension with a batch file run from my USB which will CHANGE the file extension of a designated file in the computer. im aware of the ren command but so far only managed to MAKE it rename the file extensions in the same directory. *problem solved* i managed to work it out for myselfAll it takes is sticking to it. |
|
| 1783. |
Solve : Error message too many files open? |
|
Answer» Hi there, |
|
| 1784. |
Solve : How to send the data to an application invoked from ssh? |
|
Answer» Hi All, |
|
| 1785. |
Solve : How to invoke a application from telnet? |
|
Answer» Hi All, |
|
| 1786. |
Solve : Runnig 2 batch file? |
|
Answer» Hello All, I need the second batch file to close when we execute the first one.That just won't work. Pause waits for a key to be pressed. If you want to wait for a specific time, try this. Replace xx with desired time in seconds. PING localhost -n xx -w 1000 > nulThanks for all your inputs. I will use the ping command and then send a enter keyword to the batch file. |
|
| 1787. |
Solve : Empty folders after WinRar Compression wildcard. PLEASE HELP!? |
|
Answer» Good Day |
|
| 1788. |
Solve : installing ansi.sys driver in xp pro? |
|
Answer» howcan i install ansi.sys driver in xp PRO can you help me ?WELCOME to the CH forums. |
|
| 1789. |
Solve : Reversing a string in batch? |
|
Answer» As the title suggests, I want to reverse a string/variable in batch. Eg. the input is HELLO and the output is olleh. I know it is possible in vbs, but if possible, the script needs to be put in batch.Code: [Select]echo off As always Devcom's effort is over and above. Does Devcom work for Microsoft? lol , im not here's a one liner, using gawk Code: [Select]C:\test>echo hello| gawk "BEGIN{FS=\"\"}{for(i=NF;i>0;i--)printf $i}" olleh |
|
| 1790. |
Solve : MS dos driver installation? |
|
Answer» I recently loaded an older dell dimension 2350 with freedos, it doesnt have any other os on the hd. I loaded it to play the OLD elder scrolls games, the only PROBLEM is that it doesnt detect a sound card at all, so i figured i NEED to get a driver for it. I got a generic soundblaster driver that i think should work well enough, but i dont know anything about dos really. I was wondering if SOMEONE could walk me through installing a sound driver in dos or at least point me in the right direction. Also, no i do not know what type of card it is, since i really dont know my way around dos. if it helps at all, i am using the gem gui that came with freedos.The sound card will most likely not work unless you can find a DOS driver specifically for your sound card. |
|
| 1791. |
Solve : help with deleteing files based on file name? |
|
Answer» hey all, Any thoughts would be greatly appreciated download GNU findutils(SEE my sig),and use the find command , problem solved. Code: [Select]c:\test> find_gnu.exe c:\path -type -f -name "*.avi" -mtime +30 -delete the one liner above delete avi files more than 30 days old. cheers for all the replies guys. I'm going to cheat as I found a vbs script I'd written a few years ago and managed to change a few details to get what i wanted. Thanks for all the comments. |
|
| 1792. |
Solve : Command prompt icon is in my start menu? |
|
Answer» Thank you for looking at my post. |
|
| 1793. |
Solve : MS DOS 6.2 Question? |
|
Answer» Do you know where i can get MS DOS? I did some searching and found something similar. It's called freeDOS.I have FreeDos but the problem i belive is that Windows 3.1 must have MS Dos. It is actually legal to use if you own a newer Windows OS is what i heard. Quote from: Quantos on June 26, 2009, 12:25:22 AM I just remembered, if you have Windows 95 or Windows 98 you should be able to extract MS DOS from there.Well i have 98SE, will that work? I think Windows 3.1 needs MS DOS 6.22 or older (as old as 3.0 works).MS-DOS/IBM-DOS 3.1 is the minimum required version for windows 3.1. It works with PC-DOS 2000 as well as DOS 7.1, too. Quote from: BC_Programmer link=topic=86311.msg577261#msg577261 It works with PC-DOS 2000 as well as DOS 7.1, too. [/quote So is MS Dos 7.1 in 98SE? Quantos was saying i could take the DOS from a 95/98 pc...yes, that would be 7.1. I don't know how to "extract" it from windows, but I would imagine it's done by creating a SYSTEM disk on the windows PC and copying the relevant DOS files, such as fdisk,format, find, etc. as well as performing the SYS command on the other PC's hard drive. Quote from: Cityscape on June 25, 2009, 11:11:35 PM Do you know where i can get MS DOS? Perhaps you could purchase a legal copy from someone on eBay. Here's an easier solution. Install Windows 98SE. Then install TweakUI, it can be found on the 98SE disk, or you can SEARCH Microsofts site for it. This utility installs in your Control Panel. After installing it you go to the Control Panel and click on the TweakUI icon. Then click on the Boot TAB and change the boot settings any way you want. Set it to boot without the GUI, reboot and install Windows 3.1. You owe me Quote How to Boot to a Command Prompt by Default http://support.microsoft.com/kb/141721 Quote This article describes how to configure Windows to boot to a command prompt automatically. TweakUI is a lot easier, and provides more features. Of course on the same note, he will have to get used to doing things in the command line. You can't use DOS without that knowledge. Quote from: Quantos on June 26, 2009, 04:54:09 PM TweakUI is a lot easier, Really? I've no idea... never used it. This way though, no software to install - just edit a file, and you're done. I can't imagine anything easier than that. Quote and provides more features. Of course on the same note, he will have to get used to doing things in the command line. You can't use DOS without that knowledge. Yep. But Edit is very easy to use. Heck... I wonder if he could just edit the file with Notepad? Quote Heck... I wonder if he could just edit the file with Notepad? To be completely honest I don't remember if Notepad has the priveleges to edit msdos.sys. I would recommend using the command line like the article says though. If Notepad worked I'm sure the GUY writing the article would have suggested it.Win 98SE is DOS 6.2....not DOS 7.1. |
|
| 1794. |
Solve : Copy/Sync files from network location? |
|
Answer» Hi there, well I am not to sure if this is possible; I've had a look around and being only new to writing dos based commands (in a batch file) I am stuck with trying to do the following: |
|
| 1795. |
Solve : Getting DOS 6.22 to recognize a cd drive.? |
|
Answer» Hi, Post a copy of your config.sys and your autoexec.bat.Okay, i've attached them in TEXT format. It's just a standard LG DVD-ROM drive. Quote from: patio on June 27, 2009, 04:24:56 PM Then do a search for the OakRom CD drivers...I have the OAKCDROM.sys in my C:/Dos folder. [attachment deleted by admin]These should work. Just rename them back to config.sys and autoexec.bat. [attachment deleted by admin]So where in the file do i add "DEVICEHIGH=C:\DOS\oakcdrom.sys /D:MSCD001"? and where in the other file do i add "LH C:\DOS\MSCDEX.EXE /D:MSCD001" Do they have to be in a certain place/order to work? And do i have to remove/modify ANYTHING when i add these?Use the files that I posted. They are already edited Thanks a lot!!! I've been TRYING to get this working for a month or 2. I writing this using IE 3 in Windows 3.11 now. I guess i owe you one now Quantos. We absolutely Love success stories here.... Well, that makes me feel a lot better Just for that I'm going to treat myself to a bowl of ice cream.I'm havin a Guinness myself...Guiness Ice Cream Float. Quote Guiness Ice Cream Float. I like the way that you think. Mmmm, creamy.... |
|
| 1796. |
Solve : help with move? |
|
Answer» IM tryign to exectue a move command on windows XP but when i run it it says that the syntax is incorrent. can anybody tell em whats going wrong? this is what i have so far. move c:\DOCUMENTS and Settings\[USERNAME]\folder c:\folderWhenever the path CONTAINS spaces, use quotes. Move "C:\Documents and Settings\%username%\file.txt" C:\folder That would work, and %username% is your username. |
|
| 1797. |
Solve : Append date to a file? |
|
Answer» I would like to use the copy /xcopy or RENAME command and take a file and rename it to INCLUDE the date - is that possible. REN [drive:][path]filename1 filename2 Change directories to the directory where the file in question is stored. Then type rename filenamehere.whatevertheextensionis whatyouwantittobenamed.whatevertheexten sionis do you mean datestamp? Code: [Select]for /f "tokens=2-4 delims=/- " %%a in ('date/t') do set date2=%%a%%b%%c you can then use xcopy to rename it to %date2%.ext the date will then be 06252009 if ONLY your date IS in a mm/dd/yyyyC:\>type datename.bat Code: [Select]echo off for /f "tokens=2-4 delims=/- " %%a in ('date/t') do set date2=%%a%%b%%c echo date2 = %date2% copy try.bat try%date2%.bat type try%date2%.bat Output: C:\>datename.bat date2 = 06252009 copy try.bat try06252009.bat 1 file(s) copied. type try06252009.bat ECHO OFF ECHO 1 - Stars ECHO 2 - Dollar Signs ECHO 3 - Crosses echo Enter Choice . . ,as previously said, the date/t command is dependent on regional settings of the computer. either extra batch code need to be written to take CARE of that, or just use tools that take care of that for you automatically. eg VBSCRIPT Code: [Select]Set objFS = CREATEOBJECT("Scripting.FileSystemObject") Set objArg = WScript.Arguments strFile = objArg(0) Set objFile = objFS.GetFile(strFile) today = Now yr = Year(today) mth = Month(today) dy = Day(today) If Len(mth) <2 Then mth="0"&mth End If If Len(dy) <2 Then dy="0"&dy End If strDate = mth&dy&yr newfilename = objFS.GetBaseName(strFile) & "-" & strDate & "." &objFS.GetExtensionName(strFile) objFile.Name = newfilename save the above as test.vbs and on command line Code: [Select]C:\test>cscript /nologo test.vbs file1.txt |
|
| 1798. |
Solve : my new batch program "batch editor" download? |
|
Answer» batch editor |
|
| 1799. |
Solve : Batch command needed to delete oldest file in multiple directories? |
|
Answer» I can't fight this battle anymore alone so I'm turning to this forum for help. |
|
| 1800. |
Solve : help with copy.? |
|
Answer» I'm trying to run a file from my flash drive which allows me to copy a batch file from the flash drive into a specific directory on the main COMPUTER, and then run the copied file on the computer instead of running the file from my flash drive. any help with this would be much appreciated.ok here is a code that I think will work Unless you know what the drive letter of the flash drive will be not sure it will work. If it's in the drive (not in any directories) then use %cd% and if it's on more than one computer, use %username%.I always copy STUFF to the current directory by using ".". At least for those commands that whine if I don't give a target. I use cd .. a lot, as well.unless you know what its going to be it wont help any |
|