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.
| 8001. |
Solve : track a process running time? |
|
Answer» Any commands or code could track a process running time within a batch file? Any commands or code could track a process running time within a batch file? I can no longer modify (edit ) post #1. The modify key is not available. The following batch finds the pid number and a COMMAND line argument allows the name of any process or application. C:\batch>type kill10.bat Code: [Select]@echo off sleep 600 tasklist | findstr "%1" > notepid.txt for /f "tokens=1,2 delims= " %%i in (notepid.txt) do ( echo pid=%%j taskkill /pid %%j ) Output: C:\batch>kill10.bat notepad pid=2284 SUCCESS: Sent termination signal to the process with PID 2284. C:\batch> |
|
| 8002. |
Solve : ftp command ???? |
|
Answer» HELLO (i don't KNOW english) i will if the computer connected to internet start ftp and SEND my files thank you.Don't worry about the English... What ftp program are you using ? ?in cmd ftp -s:ftp.txt ftp.txt: open my server my username my password bin put myfile.txt bye ----------------- but if computer not connected to internet don't send my file Quote from: mss9668 on April 14, 2013, 01:47:48 AM but if computer not connected to internet don't send my file Is that the problem you are FACING? Code: [Select]@echo off ping www.google.com >nul || ( echo You are not connected to the internet pause ) no.... for example : Code: [Select]@echo off cls :1 if connected to internet goto 2 if not connected to internet goto 3 :2 ftp -s:ftp.txt :3 goto 1 EDITED Code: [Select]@echo off :loop ping www.google.com >nul && (ftp -s:ftp.txt) || (goto :loop) Quote from: mss9668 on April 14, 2013, 03:37:47 AM no.... You don't NEED to use three labels. One will do. :1 if not connected to internet goto 1 ftp -s:ftp.txt Practical implementation: :1 ping -n 1 www.google.com >nul if %errorlevel% gtr 0 goto 1 ftp -s:ftp.txt or... :1 ping -n 1 www.google.com >nul || goto 1 ftp -s:ftp.txt |
|
| 8003. |
Solve : Can please help on Telnet Batch file? |
|
Answer» Hi, |
|
| 8004. |
Solve : Delete All Users Local Settings/Application Data? |
|
Answer» Our organization has sever applications that install cache and settings under the "C:\Documents and Settings\%Userprofile%\Local Settings\Application Data" directory. This is fine and dandy' until the application has an issue and need to be completely installed and REINSTALLED. At this point the cache and user file are sometimes left behind. I would like to find an easy efficient way of removing these directories. |
|
| 8005. |
Solve : Can someone create a batch file for me?? |
|||||||||
|
Answer» I am hoping someone can make me a batch file where it will automatically submit the answer at the end.
the batch file i need or the program i need would be - where it automatically validates the code. if you COPY all that info and call it whatever.html you will see it I apologize for the spam that took over your topic. It has been removed. I do not have the answer to your question, but I hope you will receive help soon.All the html code does is display 9 radio buttons and a validate button. Where did this code come from? and what exactly do you want to validate? Batch code does not have the functionality to validate web pages. What you can do is create an external script which can create an INSTANCE of a web browser (IE has a InternetExplorer.Application object; Firefox has one too but it's older than dirt and I'm not sure it will work with the newer releases). Once you create the instance you can use the methods and properties of the browser object to set values and submit the form for validation. Check out Internet Explorer Object for more help or post your questions here and we'll see what we can do. Good luck. Try http://validator.w3.org/#validate_by_input. I think it will work. But next TIME, don't post this in the MicroSoft DOS section. |
||||||||||
| 8006. |
Solve : Help - script to rename file based on size? |
|
Answer» Dear Experts, This process always repeated. Repeated FOREVER? Do you want the repetition to be instant, or with a pause? If so, how long?Quote if the size more than 500MB then close cmd.exe You cannot execute dos commands without the window opened. You can have this part in VBS or something else, or you can have the window remain open.Quote from: Lemonilla on September 10, 2013, 01:36:04 PM You cannot execute dos commands without the window opened. I don't think that is what he means, but until he comes back we won't know. |
|
| 8007. |
Solve : start hide program? |
|
Answer» HI... what open program HIDE? for example : Code: [Select]start /hide myprogram.exe Why? The forum will help people with important questions. It does not help people make a virus. no.... i need to this command You cannot hide a program with Command PromptA bit dramatic Geek to say he's makin a virus.Quote from: patio on April 14, 2013, 12:19:44 PM A bit dramatic Geek to say he's makin a virus.OK. I was dramatic. But why WOULD he want to hide it?thank you. for guide... Code: [Select]@echo off cls ( set args = WScript.ARGUMENTS num = args.Count if num = 0 then WScript.Echo "Usage: [CSCRIPT | WScript] invis.vbs aScript.bat <some script arguments>" WScript.Quit 1 end if sargs = "" if num > 1 then sargs = " " for k = 1 to num - 1 anArg = args.Item(k) sargs = sargs & anArg & " " next end if Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False )> invis.vbs wscript.exe invis.vbs myprogram.exe %* OK. An administration may run a task in the background as a schedule task. It have be minimized so that it only shows on the task bar. But it ought to be Power Shell, not command prompt. Here is a link that may offer some ideas. http://stackoverflow.com/questions/1802127/how-to-run-a-powershell-script-without-displaying-a-window |
|
| 8008. |
Solve : How to automate Outlook E-mails to PDF? |
|
Answer» Is there a WAY to automate outlook e-mail conversions to PDF? I understand creating the rule in Outlook, but automation stops because the file has to be renamed. I was wondering if there is a script that I can write into the rule that will name the file by date & time. Any help WOULD be greatly appreciated.A) export all Outlook EMAILS to SEPARATE FILES in a folder |
|
| 8009. |
Solve : Log file with "comments"? |
|
Answer» Hey guys. how come i have to set "skriv=" then set /p "skriv="? It's error checking. %skriv% can be set in the same command session and WOULD then give an incorrect comment if enter alone was pressed without typing a comment. This way it is initialised as an empty string and will only echo what is typed. |
|
| 8010. |
Solve : Batch file using NET LOCALGROUP? |
|
Answer» I am trying to find out which users are assigned to a GROUP and from that move some files to a various folders. |
|
| 8011. |
Solve : ECHO File Problem? |
|
Answer» IT Person upgraded my PC, so he copy the data from my old hard disk (drive D) and install it in new hard. Thanks for feedback, but my old disk is formatted SHORT answer is: yes, if the drive hasn't been written to. If the drive has had data written to it then you will have to try it and see if the file you need can be recovered, without corruption. |
|
| 8012. |
Solve : Batch delete file with one line? |
|
Answer» Hi Friends, |
|
| 8013. |
Solve : Changing a Bat script with a bat script?? |
|
Answer» Hey all, i have a PRETTY basic batch file scripting question. |
|
| 8014. |
Solve : checking if window is minimized? |
|
Answer» batch newbie power yeahhhhhh Perhaps it might be helpful if you told us what you are trying to do. +1 Newbies should learn early on to include the reasons, so that experienced people can figure out the best way to solve a problem from the multitude of ways available. Otherwise they get an answer that is about as useful as their question. Sorry for the rant - it just happens so often.oh, yeah, sorry. it is the batch window itself i am trying to hide. i may use visual basic for this, as i have basic knowledge of it.Using cmdow.exe, check if own window is not minimized and if not, minimize it for /f "skip=1 tokens=1,2,3,4" %%A in ('cmdow @ /P') do if not "%%D"=="Min" cmdow @ /MINQuote from: tehjoffy on September 08, 2013, 11:25:57 AM it is the batch window itself i am trying to hide. Why? |
|
| 8015. |
Solve : MASSIVE SIZE CHANGE!? |
|
Answer» I hav Attached An Example Showing Wats My Problem WHY DOES THIS HAPPEN You did something wrong. Oh by the way Quote if sumbody helped me sorting this mess,, i wud b the best ripper Quote IM [PAiN] The Master RiPpEr... Quote this is most Important Query of ma lyf |
|
| 8016. |
Solve : Remove Text From File Name? |
|
Answer» I'm stumped on how to strip text from a file name and am hoping someone can help me here. |
|
| 8017. |
Solve : Batch File to access and operate on a remote machine? |
|
Answer» Hi, |
|
| 8018. |
Solve : Batch parameters containing spaces? |
|
Answer» I am tearing my HAIR out with this. I have LOOKED at various suggested solutions but I can't get them to work. Brain Exerciser echo "%1" Thanks for the replies. Quote from: Treval on January 22, 2010, 10:14:36 AM tokens=%* or tokens=%~1 perhaps?The FOR finishes immediately when these are used. Quote from: BillRichardson on January 22, 2010, 10:30:59 AM echo "%1"This just PUTS quotes round the Brain The full string Brain Exerciser is not being passed to the echoit routine.Quote from: CHman on January 22, 2010, 09:15:22 AM I'm sure there's a simple answer but it eludes me. I am confused. Why don't you just do this? (below) Is there some reason you want to a simple thing in a complex way? for /f "delims=" %%g in (D:\Download\BackupList.txt) do echo %%g 1. Textlines.txt Code: [Select]I am tearing my hair out with this. I have looked at various suggested solutions but I can't get them to work. I have a simple batch file (D:\Download\BackupList.txt) that contains folder names: 2. Showlines.bat Code: [Select]@echo off for /f "delims=" %%A in (textlines.txt) do echo %%A 3. Output: Code: [Select]D:\Test\Batch>showlines.bat I am tearing my hair out with this. I have looked at various suggested solutions but I can't get them to work. I have a simple batch file (D:\Download\BackupList.txt) that contains folder names: Quote from: CHman on January 22, 2010, 11:32:55 AM
C:\batch>type chman.bat Code: [Select]rem Brain Exerciser rem Captures rem CpuGproj @echo off For /F "delims=" %%g in (E:\Download\BackupList.txt) do echo %%g pause For /F "delims=" %%g in (E:\Download\BackupList.txt) do call :echoit "%%g" goto :exit goto :exit :echoit echo %1 goto :eof :exit Output: C:\batch> chman.bat C:\batch>rem Brain Exerciser C:\batch>rem Captures C:\batch>rem CpuGproj Brain Exerciser Captures CpuGproj Press any key to continue . . . "Brain Exerciser" "Captures" "CpuGproj" C:\batch>Brilliant. Thanks Salmon Trout and BillRichardson, I think you've cracked it. It's the "delims=" that seems to do the trick.The DEFAULT delimiters are spaces. You can change the delimiters to any other character e.g. "delims=," makes the delimiter a comma, and "delims=" makes the delimiters the start and end of the line. Quote from: CHman on January 22, 2010, 09:15:22 AM For /F "tokens=1*" %%g in (D:\Download\BackupList.txt) do call :echoit %%g The use of tokens and a call to a LABEL will work. At least two tokens must be used. The delims between tokens is a space. When the first token is named %%g, the second token may be named %%h Code: [Select]@echo off For /F "delims=" %%g in (E:\Download\BackupList.txt) do echo %%g pause For /F "tokens=1,2 delims= " %%g in (E:\Download\BackupList.txt)do call:echoit %%g %%h goto :exit goto :exit :echoit echo %1 %2 goto :eof :exit RUN C:\batch> chman2.bat Brain Exerciser Captures CpuGproj Press any key to continue . . . Brain Exerciser Captures CpuGproj C:\batch> |
|
| 8019. |
Solve : edit file options? |
|
Answer» Hi folks, Hi folks,What you say SOUNDS like an old thread on another forum. http://stackoverflow.com/questions/3644238/split-text-file-in-two-using-bash-script You can use either AWK or SED for windows. Microsoft has not offered any Windows versions of these because the versions available for windows work fine. OR Use the Power Shell work-alike: http://windows-powershell-scripts.blogspot.com/2009/06/awk-equivalent-in-windows-powershell.html That should be enough to get you going. |
|
| 8020. |
Solve : Networking Batch File? |
|
Answer» Dear All, Hmm,,, I tested my last contribution and it works fine. What do you see on the screen?Quote from: foxidrive on April 18, 2013, 03:46:01 AM I tested my last contribution and it works fine. What do you see on the screen?From what I can see, the code the OP posted is not your most recent contribution, but is just the code from lemonilla with the loop removed. Maybe the OP wants to run the EXE file when the connection is down, and then continue to test for a connection, but only run the EXE once. That is complicated by the fact that the connection could flutter and go up and down rapidly. We'd need to know how he wants to handle that.Hi All, Below is my Query to make a batch file : 1. My ping to Google.com should continuously be on so that i can see the reply from the site 2. As my link goes down (Request time out) it should give me an pop of an .exe file (which i have made) only once, and it should continuously check the connection when it comes up. Regards, Saravanan My ping isn't working in general, try this out, and see if it works (or if it's close to what you want.) Code: [Select]@echo off set a=0 :loop ping www.google.com -n 1 >nul 2>&1 if "%errorlevel%"=="0" set a=0 if "%errorlevel%"=="1" if "%a%"=="0" call :loss goto loop :loss start FILE.exe set a=1 goto :eof Hi Lemonilla, the command which u gave me last one, when ever i used to run it, it just shows blank cmd screen. Please help me on the below command : ******************************************************************************* @echo off :PING ECHO Checking connection, please wait... PING -n 1 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :TRYAGAIN :TRYAGAIN ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO FAILURE! ECHO Let me try a BIT more, please wait... @echo off start /d "c:\Ping files\Link Files" et.exe PING -n 3 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :FAILURE :SUCCESS ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO You have an active Internet connection ping www.google.com -w 4 goto PING :FAILURE ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO Kindly Check the connection.........! ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- goto PING sleep 20 :END ******************************************************************************* When i run the above batch file I get: "Please see the screen shot 1.jpg as attached" and when i disconnect my network cable I get: "Please see the screen shot of 2.jpg as attached" So in this i just want that it should display only once the error "ET link is down" when the link goes down. and it should keep checking the link status.... So can you please modify on the above program and resend at the earliest. Hope you got my needs Thanks, Regards, Saravanan [recovering disk space, attachment deleted by admin]try: Code: [Select]@echo off set a=0 :PING ECHO Checking connection, please wait... PING -n 1 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :TRYAGAIN :TRYAGAIN ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO FAILURE! ECHO Let me try a bit more, please wait... @echo off if "%a%"=="1" start /d "c:\Ping files\Link Files" et.exe PING -n 3 www.google.com|find "Reply from " >NUL IF NOT ERRORLEVEL 1 goto :SUCCESS IF ERRORLEVEL 1 goto :FAILURE :SUCCESS set a=1 ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO You have an active Internet connection ping www.google.com -w 4 goto PING :FAILURE set a=0 ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- ECHO Kindly Check the connection.........! ECHO ------------------------------------------------------- ECHO ------------------------------------------------------- goto PING %a% holds the value of the last ping (success/failure). When it checks to run your exe, it checks to see if the last ping was a failure, and then does not run. About the blank screen, I did that purpusfuly, as I figured it would run in the background and would be annoying with lots of flashing text. Here is some with text: Code: [Select]@echo off set a=1 :loop ping www.google.com -n 1 >nul 2>&1 if "%errorlevel%"=="0" ( if "%a%"=="1" cls if "%a%"=="1" echo Connected set a=0 ) if "%errorlevel%"=="1" if "%a%"=="0" call :loss goto loop :loss cls echo Connection Error. echo Reconnecting. . . start /d "c:\Ping files\Link Files" et.exe set a=1 goto :eof It should write only "Connected" while connected, and write "Connection Error. Reconnecting. . . " while not. You will have to test it to check though. Also changed 'start FILE.exe' to 'start /d "c:\Ping files\Link Files" et.exe' from your code.[/code]alt + printscreen for screen shots!Hi Lemonilla, Awesome...... it has started working, thanks a lot, it was a excellent help by you... One last thing in the last program you have edited and send to me... in that when the .exe file runs can that .exe file is it possible to display on the other computer which is in the network. Regards, Saravanan. U |
|
| 8021. |
Solve : renumbering files using .BAT? |
|
Answer» Hi All, Move a series of sequentially numbered files (ex: Az_361.tif - Az_720.tif) to a new folder and renumber not rename (ex: they are now Az_001.tif - 360.tif). The old numbers are part of the file name:AZ_361.tif. And the new numbers are part of the file name. You are renaming the files. Copy the files, rename the files with new numbers as part of the name. If all works well, del the ORIGINAL files. A batch file with a for loop and number generator will do the job.Code: [Select]@echo off REM ren may misfire with long file names. REM Use dir /x for short name list REM C:\>dir /? rem /X This displays the short names generated for non-8dot3 file rem names. The format is that of /N with the short name inserted rem before the long name. If no short name is present, blanks are rem displayed in its PLACE. REM Az_361.tif - Az_720.tif) to a new folder and rename REM (ex: they are now Az_001.tif - 360.tif). setLocal EnableDelayedExpansion rem dir /b *.tif > tiffiles.txt set N=0 for /f "tokens=* delims= " %%a in (tiffiles.txt) do ( set /a N+=1 set var=%%a ren !var! AZ00!N!.tif ) dir /b AZ* dir /b *.tif Output: C:\batch> numfiles.bat . . . AZ004.tif AZ005.tif AZ006.tif AZ007.tif . . . C:\batch>ren might work better with a shorter name Instead of: ren !var! AZ00!N!.tif use: ren !var! AZ!N!.tif Thanks Bill, This is a big help. I figured out how to generate a batch move list with using C++, but this is what I was trying to do in the first place. Tony |
|
| 8022. |
Solve : Trying to find ip of printer connected to network? |
|
Answer» I did arp -a to GET all ips on network, |
|
| 8023. |
Solve : Compress file using Windows 7 zip utility? |
|
Answer» Hello, I am trying to zip a file using the zip utility that comes with windows 7, how can I do this in a batch file? I can not download any third party software and have to use what is included in windows due to admin rights. |
|
| 8024. |
Solve : Refining net view command in batch? |
|
Answer» I am trying to make a batch FILE that simply outputs the name of every computer on the network. The problem is that "net view" command decides that it needs formatting and labels. I just want the computer names. So I am making a batch to strip out all of the unnecessary labels and stuff. It works well, BUT it says 2==\\ is unexpected at this time when reading the last line. I FIGURE that this is because the last COUPLE of lines in the net view list file are blank, but I don't know how to tell it to skip blank lines. Could someone please help me make this run without errors. GOTO:EOF before the line containing :CheckIt AND Quote use quotes or brackets. Here is the finished batch file. It can scan computers using net view or with a list of computers stored in comps.lst. The default method is using comps.lst so if you try it you will need to make a comps.lst file. You will also probably have to change the location of the temp file because I have it set to "B:\comps.tmp" for my RAM drive. Comps.lst should look like this: Code: [Select]bla bla bla this is ignored \\server more comments \\seccondserver Here is the batch: Code: [Select]@echo off setLocal EnableDelayedExpansion set tmpfile=B:\comps.tmp call ::initnewline if "%1"=="-?" goto help if "%1"=="-a" ( echo Using autoscan mode. net view > %tmpfile% ) else ( echo Using comps.lst mode. copy /Y comps.lst %tmpfile% >nul ) echo Getting comp names. . . echo Type whatson -? for modes. echo Checking comps. Please wait. . .%NL% for /F %%i IN (%tmpfile%) do call ::CheckIt %%i echo %NL%Any key to exit. . . pause >nul goto:EOF :CheckIt set line=%1 set line=%line:~0,2% if not "%line%"=="\\" goto:EOF set line=%1 set line=%line:~2% ping -n 1 %line% >nul if errorlevel 1 ( echo %line% is off. ) else ( echo %line% is on. ) goto:EOF :initnewline REM extra empty lines required set NLM=^ set NL=^^^%NLM%%NLM%^%NLM%%NLM% goto:EOF :help echo Type whatson -a to automatically scan for comps. echo Type whatson -n or just whatson to use the list echo of computers in the comps.lst file. echo Any key to exit. . . pause >nul |
|
| 8025. |
Solve : Loading and playing old DOS games in MS-DOS? |
|
Answer» I would like to PLAY some of the early Ultima DOS games in MS-DOS instead of trying to run them through windows. Is that possible on a windows 95 computer?Have you tried it? A Win95 machine should play most dos games.I haven't tried it yet. I was going to get the Ultima 1-8 package which are probably some of the oldest dos games there are. I was reading reviews how they run badly in windows and thought running them in DOS would give them the best shot. It wouldn't hurt to try windows first but I would like to find some info on how to run them from dos since that is what they were made for.Quote from: Amats on April 29, 2013, 09:12:54 AM I was reading reviews how they run badly in windows Windows 95/98/ME/W2K/XP/Win7/Win8? Which windows? Why not just give DOSBox a try ? ? I was going to suggest that - but the spec PC in his SIG shows an old machine - and DOSBOX is very slow on a 3.5 GHz I7 Quad core machine. At least for SkyGlobe it is. Maybe Virtualbox using MSDOS would give better SPEED than DosBox... (if Virtualbox runs under Win95 - that's not likely) or an older version of VMware.I may misunderstand but wouldn't you want it to slow down an i7 for older DOS games ? ?Emulators generally have an automated throttle to slow them down to real frame speed - when they are fast emulators. My point is that running a slow emulator on a 466 MHz machine means it is going to be even slower. I had nowhere near real speed in SkyGlobe on my I7 box.Why not just get an old PC from a thrift shop?Quote from: foxidrive on April 29, 2013, 08:46:22 PM I had nowhere near real speed in SkyGlobe on my I7 box.This is off-topic, and I don't know specifically what you use that software for, but you could try a program like Celestia.Thanks for the thought.The Ultima series of games (1-8) came out for the Atari 8 bit 400/800/XL/XE and Commodore 64 systems and I don't know what others it was programmed for and reviews SAY the early ones run very fast but instructions are given for how to make them playable so I think I will just get the 1-8 package and see what it takes to run it. Should be an interesting experience to see the way it used to be. |
|
| 8026. |
Solve : Opening multiple IE in different windows not in one Window as a tabs!? |
|
Answer» Hi,
The following information might help: http://support.microsoft.com/kb/281679 or http://www.tech-recipes.com/rx/1164/internet-explorer-7-open-new-windows-in-tabs-in-ie7/ Tools, Internet Options, Tabs, Settings . . . ( below) In batch file simply write : Code: [Select]start iexploreit always open IE as a new window .Start "" iexplore http://www.google.ca start "" iexplore http://www.hotmail.com That should work. |
|
| 8027. |
Solve : The Ren Command Glitch?? |
|
Answer» If I create a file LIKE this ... If I create a file like this ... You are mistaken. Some thing else happened while you were testing. d:\abc>dir /b my.bla.jpg d:\abc>ren *.jpg.bla *.jpg The system cannot find the file specified. Quote from: guideX on April 30, 2013, 11:21:31 PM If I create a file like this ...Surely you meant file like this ... "my.jpg.bla" which then matches the filespec for the rename. This behaviour is not a glitch, the filename is my.jpg, the extension is .bla to rename it the way you want, simply rename it without an extension, thus ren *.jpg.bla *. now the .jpg from the name is PROMOTED to the extension simples Whoops! Let me CORRECT my experiment, and give a little more information.. I'm using Windows 7 64bit cmd. 1) Create a file, called m.txt.bla 2) Type ren *.txt.bla *.txt (logically, you should have a file m.txt) 3) You now have a file called m.txt.txt To me this make little sense, and I'd suggest it's a glitch. I did encounter it as working when you use ren *.jpg.bla *. however, this also seems like a glitch ... If I did this command, wouldn't I end up with a file called "my."? Quote from: gpl on May 01, 2013, 05:05:57 AM Surely you meantQuote from: guideX on May 01, 2013, 06:38:47 PM I did encounter it as working when you use ren *.jpg.bla *. however, this also seems like a glitch ... If I did this command, wouldn't I end up with a file called "my."?no, its not a glitch, the extension follows the last dot - the name of the file is my.jpg, the filetype is bla |
|
| 8028. |
Solve : Trying to figure out how to do this, should be simple, but hit a wall? |
|
Answer» So I have an old 80GB external hard drive at E:\ that has data some of it redundant scattered like a mess among many directories and I WANT to copy all files on this external hard drive to a single folder at C:\cleanedup\ but the part that I am stumped on is how to get a copy of all files to C:\cleanedup\ with an xcopy /d/y so that I only get the newest file of redundant file copied to C:\cleanedup\ and not have the directory paths reconstructed at c:\cleanedup\ E:\>%a\*.* was unexpected at this time. Any suggestions on how to correct this? OS of system I am testing this on is Windows XP Home SP3Code from stackoverflow - it's a command line and you need to double all % to execute it in a batch file. Code: [Select]for /d %a in (*) do @copy %a\*.mp3 e:\myfolder It won't handle filename collisions. The easiest way to handle this is to add a counter to each filename, so they are unique names. filename 0001.ext apple 0002.ext apple 0003.ext banana 0004.ext etcHello Foxidrive... thanks for your help. I forgot about using the extra % as an escape character. In regards to appending a number to the end of the files... I was looking into if DIR /S /B /O:d could be used to sort all files by oldest first and newest last so that the order that the batch executes, the newest like file name would overwrite the oldest. But its not working as intended and not sure why? Here is the latest one I created: Code: [Select]for /f "delims==" %%k in ('dir e:\*.* /s /b /o:d') do copy "%%k" f:\test1\ pause Looking at the /O switch for DIR, it looks as if I should be able to pass the output from DIR to the FOR loop and process oldest first and then newest last as the order in which the DIR output is oldest files first and newest files last, so it should be the same as an xcopy /d switch that overwrites the old same file name with the new same file name. ( But not working out as intended when testing ) Quote C:\>dir /? My test was 3 folders such as folder1, folder2, and folder3 all containing a same test.txt file. In folder2 I have the newest date/time stamp version to test if its executing the process alpha numeric order or by the DIR O/:D method that should place them in an order in which it should be: folder1\test.txt folder3\test.txt folder2\test.txt so the latest/newest date time stamp file in folder2 should be the last file of like file name to write to the destination, but it seems to still be executing alpha numerically as folder1, folder2, and folder3 since the file written to the destination is the date/time stamp of that of the same date/time stamp that is on the test.txt file in folder3 .... so kind of stumped as to why its not working as I believe it should The one way i can see this MAYBE malfunctioning is if its looking only at the roots of each folder to sort the files by date/time in which in will process the transfer alpha numerically but oldest to newest in each folder not taking into account the oldest from newest in neighboring folders. Here is the output showing the process of transfer, which seems alpha numeric still when it shouldnt be with the DIR /O:D I would think. Quote Z:\>for /F "delims==" %k in ('dir e:\*.* /s /b /o:d') do copy "%k" f:\test1\ So the last: Z:\>copy "e:\folder3\test.txt" f:\test1\ 1 file(s) copied. Is the last file to overwrite the destination when it should be the file located at folder2\insiderfolder\test.txt which has the newest date/time stamp among all like files at E:\> <<< Update: >>> Just tested the DIR /O:D and DIR /O:-D inverse and it appears that it only sorts the root directory files and not subdirectories Is there a way to make it look at subdirectory date/time stamps to sort the order oldest to newest? Quote E:\>dir Excuse me for not following all your text - DIR will sort in a folder, but not in a folder tree. You can use this code to get a list of timestamps and filenames. Code: [Select]@echo off cd \ del \list.txt 2>nul for /r %%a in (*) do >>\list.txt echo %%~ta %%a The resulting list.txt file can be changed to list in yymmdd hhmm format and then sorted to give you a list of oldest to newest file, but to make this easier it will help to change your msdos date and time format to yyyy/mm/dd and 24 hour time hh:mm and change it back to what you prefer afterward. Even just changing to 24 hour time will help to rewrite the file in a sortable format. If you want to use this method (you can use this sorted file to easily copy all the files) then supply a few lines of the list.txt file and someone can help massage it into a sortable format. Thanks for your help foxidrive ... going to play around with suggestions and see if I can make it work somehow, but I have some doubts I will be able to get it to work because DOS has been around for many years and google is generally good at coming up with hits with other people that wanted to do something a certain way before yourself, and those who have and have instructions listed that can be placed into batches all dont seem to do the trick. The biggest issue is that DIR only works with the local folder that it is targeting and not with directory trees as you said and I have seen in testing. Have also come across a tool called xxcopy that I am going to check out. Never used it before and the google search for info on doing what I am trying to do has had info suggesting that others have used it for this purpose possibly. Definately going to play around with the code you supplied though as for with all files in a list.txt in an order from oldest to newest etc, depending on what is written to this file, I could import that list to C++ or Perl and maybe process this list to transfer all files from start to finish to the single folder from oldest files first to newest files last so that only the newest version is located at the destination as for any processed prior of the same file name would be overwritten due to the order of processing the file copying. Just wanted to follow up with the end result of what I ended up going with to ACHIEVE what I needed. After lots of digging, I found that XXCOPY with the /SGNO switch will copy all files from a source with directory tree all to 1 location collapsing the directory tree and it keeps the newest files of like file names in what it copies. I DOWNLOADED the freeware version and it works flawlessly on my Windows XP Home SP3 Netbook that I tested it on with a flash drive as the source drive with test files in a junk test tree. Below is the first run of it with test data in a test tree with data hidden in subdirectories. Quote C:\>xxcopy f:\*.* c:\crush1\ /SGNO I then tested to see if xxcopy acted like xcopy in that it would update/copy over only the single file that changed, and it did as seen below. Quote C:\>xxcopy f:\*.* c:\crush1\ /SGNO So I'm all set and thanks for help. I wanted to post back with what I ended up doing so that anyone else in the future who finds this will save themselves hours of trial and error trying to get it to work. |
|
| 8029. |
Solve : output on second batch? |
|
Answer» hi all type chat.txt display.bat Code: [Select]@echo off mode 20, 32 setlocal disableDelayedExpansion set user=user :loop echo --- type chat.txt echo --- cls goto loop input.bat Code: [Select]@echo off mode 20, 4 title taip in color 02 if exist chat.txt del chat.txt if not exist chat.txt echo Welcome to chat system >>chat.txt :loop set /p message= echo %user%: %message%>>chat.txt goto loop now how can i make content in chat.txt like this Quote user=kaka and on display.bat show like this Quote kaka: message1because its easy i want to make kaka different color Quote kaka: message1 this code i able made so far display.bat Code: [Select]@echo off mode 20, 32 title start6 start input.bat setlocal disableDelayedExpansion set user=kaka set q=^" echo( call :c 02 "%messageV%" /n call :c 04 "%messagex%" /n call :c 02 "%downloadV%" /n call :c 04 "%downloadx%" /n call :c 02 "%doneV%" /n call :c 04 "%donex%" /n :loop echo --- type chat.txt echo --- ping -n 3 localhost >nul cls goto loop :c setlocal enableDelayedExpansion ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :colorPrint Color Str [/n] setlocal set "s=%~2" call :colorPrintVar %1 s %3 exit /b :colorPrintVar Color StrVar [/n] if not defined DEL call :initColorPrint setlocal enableDelayedExpansion pushd . ': cd \ set "s=!%~2!" :: The single blank line within the following IN() clause is critical - DO NOT REMOVE for %%n in (^"^ ^") do ( set "s=!s:\=%%~n\%%~n!" set "s=!s:/=%%~n/%%~n!" set "s=!s::=%%~n:%%~n!" ) for /f delims^=^ eol^= %%s in ("!s!") do ( if "!" equ "" setlocal disableDelayedExpansion if %%s==\ ( findstr /a:%~1 "." "\'" nul <nul set /p "=%DEL%%DEL%%DEL%" ) else if %%s==/ ( findstr /a:%~1 "." "/.\'" nul <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%" ) else ( >colorPrint.txt (echo %%s\..\') findstr /a:%~1 /f:colorPrint.txt "." <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" ) ) if /i "%~3"=="/n" echo( popd exit /b :initColorPrint for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "DEL=%%A %%A" <nul >"%TEMP%\'" set /p "=." subst ': "%temp%" >nul exit /b :cleanupColorPrint 2>nul del "%temp%\'" 2>nul del "%temp%\colorPrint.txt" >nul subst ': /d exit /b input.bat Code: [Select]@echo off mode 20, 4 title input setlocal disableDelayedExpansion set user=kaka set messagev=message sent set "messagex=message fail" set downloadv=download finished set downloadx=download failed set donev=done set donex=failed set q=^" echo( call :c 02 "%messageV%" /n call :c 04 "%messagex%" /n call :c 02 "%downloadV%" /n call :c 04 "%downloadx%" /n call :c 02 "%doneV%" /n call :c 04 "%donex%" /n :loop set /p message= echo %user%: %message%>>chat.txt call :c 04 "%user%:"&call :c 0b "%message%" /n goto loop :c setlocal enableDelayedExpansion ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :colorPrint Color Str [/n] setlocal set "s=%~2" call :colorPrintVar %1 s %3 exit /b :colorPrintVar Color StrVar [/n] if not defined DEL call :initColorPrint setlocal enableDelayedExpansion pushd . ': cd \ set "s=!%~2!" :: The single blank line within the following IN() clause is critical - DO NOT REMOVE for %%n in (^"^ ^") do ( set "s=!s:\=%%~n\%%~n!" set "s=!s:/=%%~n/%%~n!" set "s=!s::=%%~n:%%~n!" ) for /f delims^=^ eol^= %%s in ("!s!") do ( if "!" equ "" setlocal disableDelayedExpansion if %%s==\ ( findstr /a:%~1 "." "\'" nul <nul set /p "=%DEL%%DEL%%DEL%" ) else if %%s==/ ( findstr /a:%~1 "." "/.\'" nul <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%" ) else ( >colorPrint.txt (echo %%s\..\') findstr /a:%~1 /f:colorPrint.txt "." <nul set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" ) ) if /i "%~3"=="/n" echo( popd exit /b :initColorPrint for /f %%A in ('"prompt $H&for %%B in (1) do rem"') do set "DEL=%%A %%A" <nul >"%temp%\'" set /p "=." subst ': "%temp%" >nul exit /b :cleanupColorPrint 2>nul del "%temp%\'" 2>nul del "%temp%\colorPrint.txt" >nul subst ': /d exit /b The only way I know of to make words diffrent colors on batch only works on Windows 7, and I don't quite understand it. Here is the code, It can't do special characters Code: [Select]@echo off SETLOCAL EnableDelayedExpansion for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a" ) echo say the name of the colors, don't read call :ColorText 0a "blue" call :ColorText 0C "green" call :ColorText 0b "red" echo. call :ColorText 19 "yellow" call :ColorText 2F "black" call :ColorText 4e "white" pause goto :eof :ColorText echo off <nul set /p ".=%DEL%" > "%~2" findstr /v /a:%1 /R "^$" "%~2" nul del "%~2" > nul 2>&1 goto :eof Try this out (as it's own program) and SEE if it runs. You must include the loop at the top, and the :ColorText at the bottom (after the 'exit'). You will have to use a FOR /F to apply this to chat.txt.Quote The only way I know of to make words diffrent colors on batch only works on Windows 7, and I don't quite understand it. Here is the code, It can't do special characters Thanks for sharing this Lemonilla ... Just learned something new. With batch the color change use to always change all text on the display. And with old Basic the color x,y,z command use to change the entire lines color to whatever the last color call was prior to line return, which was slightly better, but never achieved the multiple colors on a single line until making websites with HTML..LOL Interesting that microsoft added this ability to command shell/batch. |
|
| 8030. |
Solve : batch file that deletes a file based on date in filename? |
|
Answer» Hi everyone, Hi everyone, the only other date data files have is "Date last accessed"...I'm not looking to use date modified, accessed or created. I would like to base this off of the date I have in the filename.Do you have ADMIN privileges which allow you to download/install a small utility program?no, i do not have admin privileges.Quote from: tmoe30 on January 20, 2010, 03:12:32 AM I'm not looking to use date modified, accessed or created. I would like to base this off of the date I have in the filename. The date created and the date in the file NAME might be the same? Can you POST the batch file that renamed the date file? That same batch file might be modified to delete the date file?Quote from: tmoe30 on January 20, 2010, 03:12:32 AM I'm not looking to use date modified, accessed or created. I would like to base this off of the date I have in the filename. Is the following batch file similar to the batch file that renamed the testfile.txt to testfile01202010.txt C:\batch>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% echo hello > testfile.txt ren testfile.txt testfile%date2%.txt dir testfile%date2%.txt rem AT 14:30 NEXT:90 "del c:\batch\testfile01202010.txt" rem The above has not been tested rem * below rem testfile01152010.txt Output: C:\batch>datename.bat date2 = 01202010 Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 01/20/2010 07:45 PM 8 testfile01202010.txt 1 File(s) 8 bytes 0 Dir(s) 303,377,936,384 bytes free C:\batch> _______________________________________ ______ http://www.instructables.com/answers/Is-there-a-batch-script-that-you-can-compile-and-/ * Let the cron, the AT command or the scheduler do the date math. A better way of doing what you want is to use the built-in scheduler. To get to this, go to Control Panel then Scheduled Tasks. You can run any program you like (including batch files) from there. You can also set up the scheduler from a batch file, which is closer to what you're after. It can run once, or every hour, week etc. You need to use the AT command, so your set-up batch would be something like : rem AT 14:30 NEXT:90 "del c:\batch\testfile01202010.txt" rem The above has not been tested by Bill Richardson Quote from: tmoe30 on January 20, 2010, 03:12:32 AM I'm not looking to use date modified, accessed or created. I would like to base this off of the date I have in the filename. A slight modification from above. How to save 90 days, wakeup and delete? C:\batch>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% echo hello > testfile.txt ren testfile.txt testfile%date2%.txt dir testfile%date2%.txt dir /b testfile%date2%.txt dir /b testfile%date2%.txt >> save90.txt rem AT 14:30 NEXT:90 "del c:\batch\testfile01202010.txt" rem The above has not been tested by Bill Richardson rem testfile01152010.txt Output: C:\batch>datename.bat date2 = 01202010 Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 01/20/2010 08:01 PM 8 testfile01202010.txt 1 File(s) 8 bytes 0 Dir(s) 303,377,649,664 bytes free testfile01202010.txt C:\batch>Quote from: tmoe30 on January 20, 2010, 06:06:22 PM no, i do not have admin privileges. Okay. Try the script below. There is no provision for paths/filenames containing spaces and the script is not fully tested. Please ensure you have a secure testing environment when you remove the rem from the If/Del command line. Good luck. Code: [Select]@echo off cls setlocal enabledelayedexpansion :: With acknowledgement to Dias de verano :: Compares the current date -90 days with the date in the filename :: of files named testfilemmddyyyy.txt and deletes the file if it :: is 90 or 90+ days older than current. set vb=%temp%\newdate.vbs ( echo Newdate = (Date(^)-90^) echo Yyyy = DatePart("YYYY", Newdate^) echo Mm = DatePart("M" , Newdate^) echo Dd = DatePart("D" , Newdate^) echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd )>>%vb% FOR /F "tokens=1-3" %%A in ('cscript //nologo %vb%') do ( set Yyyy=%%A set Mm=%%B set Dd=%%C ) set olddate=%Yyyy%%Mm%%Dd% echo Old date = %olddate% del %vb% for /f "delims=." %%1 in ('dir /b testfile*.txt') do ( set filename=%%1 set filedate=!filename:~-8! set filedate=!filedate:~-4!!filedate:~0,2!!filedate:~2,2! echo Filename date = !filedate! rem if !filedate! leq !olddate! del !filename!.txt ) |
|
| 8031. |
Solve : create 13letter combination? |
|
Answer» hi all...i hope some one will help me fast as possible Ah, movie password cracker programs... in a real program you would not waste time echoing the trial passwords to the screen... and would anyone choose a password like aaaaagzzzzzzz ?Thank you! I will use it! If real password (generator) crackers were used in movies it would make for a very very long and boring movie that would go on for days, MONTHS, or maybe even years depending on complexity, and might not end in the lifetime of the director! Those scenes where someone gains access in less than 10 seconds and you see characters and or digits scrolling or scrolling and locking on matches is completely ALL HOLLYWOOD!!! The fastest crack would be if it was strictly 13 digits 0 - 9 in which you have 10,000,000,000,000 combinations, but that still would take a long time, just not as long as ones with Alpha involved. A good realistic security system in a 007 movie for example with extremely restricted access would probably send a silent alert upon the 5th attempt to enter a password and entering it wrong, should have doors that would lock the person into a controlled space between the last door entered locked shut and the next door they are trying to get past. This system would not allow for the code to be intered unless the door behind them was shut, and sensors could not be overriden which sense for doors position. Then they would get hauled away and likely killed after the 5th wrong password with generator... most people want Bond to Live! ... LOL So that is why most of the time its a retna scanner with a contact etc, fake fingerprints, and so on for fooling biometric security SYSTEMS. Scenes like Terminator 2 where John Connor rips off an ATM with his friend for arcade money with an account/pin generator are strictly a laugh or "Give me a break" factor for those who know better!!! In addition to this, many systems that are used for password authentication in the real world especially for computer or server access will block any further attempts after so many failed attempts were made within a given period of time. Any system not having a lock out is just extremely dumb and left to the movies to display extremely poor security systems. I created a table that shows just how complex and how long cracking a 13 character password would be for both Alpha and Alpha-Numeric with a generator that tests ALL COMBINATIONS. With home computers unless you own warehouses full of them and have each one cracking a segment of the whole of all possible combination of possibilities, the odds are greatly against you that it will get cracked in many many lifetimes. The computer is likely to let out its secret smoke long before it gets to a match. However if the password was aaaaaaaaaaaaa and the program started at aaaaaaaaaaaaa and ended at zzzzzzzzzzzzz it would start and find a match immediately, however if it is zzzzzzzzzzzzz it is likely not to happen in your lifetime unless computers become way way more powerful or you have a huge team of systems to use combined processing power of and you allocate smaller chunks of range to generate and test against, and the system that is receiving the password attempts does not get flooded or lock you out. If there is no lockout, there is likely a flood condition where it is overwhelmed, UNLESS you are able to farm the hive of the security system and run this locally at each computer that is looking for a match. The hive being an encrypted pool of passwords that the real system has and you can test against, its very much not likely to happen in your lifetime. That is why dictionary attacks, social engineering someone to giving away the password, keyloggers, exploits by phishing, packet sniffers, etc are used to gain access and password generators are really not the way to go. In relation to what you are trying to generate, I generated 4 places with a Perl script using the FOR A to ZZZZ instruction and writing output appended to a file, and it took a while to complete on my netbook. 456,976 combinations in all, and VERY VERY lengthy text file! [recovering disk space, attachment deleted by admin]Not sure why anyone is even assisting with this here....I pretty much wanted to show how UNREALISTIC such a generator was by example Quote from: patio on May 30, 2013, 06:23:12 PM Not sure why anyone is even assisting with this here....We are bored Quote We are bored LOLLLLL Password programs use multi-GPU these days and are orders of magnitude faster than a one using a CPU.Quote from: foxidrive on May 30, 2013, 08:25:06 PM Password programs use multi-GPU these days and are orders of magnitude faster than a one using a CPU.Citation requested. I often forget my passwords and so I need one of these. |
|
| 8032. |
Solve : Get File Name using Batch? |
|
Answer» SCENARIO:- A new right click option "Get File Name" is implemented for a particular extension ..lets say for .txt The option "Get File Name' is added for the txt file using Regedit and the action for "Get File Name" is pointed to a batch script. So when the Get File Name option is selected , the FILENAME which called the script along with the path has to be copied into the batch. Please provide your ideas and suggestions how to implement the above..ThanksQuote from: jack64 on June 04, 2013, 11:41:29 AM when the Get File Name option is selected , the filename which called the script along with the path has to be copied into the batch. By "the filename which called the script" do you mean the "name of the file which was right clicked by the user"? Exactly!!!!!!!I bet it's held in %1. In a batch script, the replaceable parameter %1 contains the first (or only) parameter passed to the script. If it contains a valid file name, it can be modified with the standard variable modifiers (see the FOR documentation for details - type FOR /? at the prompt) ~d is drive, ~p is path, ~n is name, ~x is extension. %1 is the raw parameter If it is a file name, it may already hold the full drive and path, but you can check with simple tests echo %1 echo %~d1 echo %~p1 echo %~n1 echo %~x1 They can be combined: echo %~dpnx1 Passed to a variable: set parameter=%1 echo Parameter is: %parameter% (etc) So try that & report results if you need further help. %0 is the name of the batch file that is being executed. %1 is the first argument from the calling program. Same modifications apply to %0 as to %1 Code: [SELECT]C:\users\lemonilla>batchFile.bat argument1 argument_2 argument-3 "Argument 4" If you entered this into command prompt, %0 = "C:\users\lemonilla\batchFile.bat" %1 = argument1 %2 = argument_2 %3 = argument-3 %4 = "argument 4" %5 = Undefined %6 = Undefined %7 = Undefined %8 = Undefined %9 = UndefinedQuote from: Lemonilla on June 05, 2013, 01:38:43 PM %0 is the name of the batch file that is being executed. %0 unmodified is the command line that was used to call the batch. paramtest.bat (in FOLDER c:\Batch) Code: [Select]@echo parameter 0 is %0 Code: [Select]c:\>paramtest parameter 0 is paramtest c:\>paramtest.bat parameter 0 is paramtest.bat c:\>c:\Batch\paramtest.bat parameter 0 is C:\Batch\paramtest.bat However... paramtest2.bat (in c:\Batch) Code: [Select]@echo this script is %~dpnx0 Code: [Select]c:\>paramtest2 this script is c:\Batch\paramtest2.bat Note: in the above examples, the folder c:\Batch is on my PATH. |
|
| 8033. |
Solve : help me with movement please?? |
|
Answer» I am messing around in batch creating some games and some of my favorite games, but I need help with something. |
|
| 8034. |
Solve : another newbie batch file question? |
|
Answer» im making a text-based rpg. i HEARD thats a good way to flex your batch file skills. |
|
| 8035. |
Solve : Batch file to alter m3u file (Newbie request)? |
|
Answer» Hi, |
|
| 8036. |
Solve : Batch file - Multiple files to a command at once? |
|
Answer» Hello everyone, I am new to this forum. Secondly, is there a way to "DO" multiple commands within the FOR? FOR %%variable IN (set) DO ( command1 [command parameters] command2 [command parameters] commandn [command parameters] ) Beware of setting variables within the loop, you will need to use delayed expansion, or they won't work! Quote from: Dias de verano on September 23, 2008, 11:42:59 AM I think the separator for multiple input files is white space not a comma, and that implies that filenames which contain spaces need quote marks before and after. Not only white space, but commas, semi-colons and equal symbols are perfectly acceptable to the interpreter for use as separators. To guard against space embedded file names, the original code brackets each file NAME with quotes: Code: [Select]@echo off setlocal for %%x in (*.wav) do ( call set strCmd=%%strCmd%%,"%%x" ) set strCmd=%strCmd:~1% "g:\program files\flac\flac.exe" %strCmd% endlocal Quote from: Sidewinder on September 24, 2008, 04:14:42 AM Not only white space, but commas, semi-colons and equal symbols are perfectly acceptable to the interpreter for use as separators. I'm not talking about "the interpreter", I'm referring to flac.exe Oops! From what I could find out the OP's original code was correct. I didn't find any examples of how to send multiple files to flac.exe other then iterating a directory. Examples Flac FAQ Quote from: Sidewinder on September 24, 2008, 11:35:49 AM Oops! From what I could find out the OP's original code was correct. I didn't find any examples of how to send multiple files to flac.exe other then iterating a directory. Indeed. This suggestion from the FAQ, in answer to the question "why don't wildcards work?"... Quote for %F in (*.wav) do flac "%F" That is a command line example - double up the % signs if including in a batch. This implies that flac can only do 1 input file at a time, and that the answer to the OP's question, which was... Quote Problem is, each file was being sent one at a time. I need to find a way to send all the files in the directory to the program at once. ...is, "Sorry, there isn't a way to do that, because flac.exe won't accept multiple file names" I'd be interested to know why the OP WANTS to send multiple filenames all at once to flac.exe, SINCE even if it could accept them, it would still process them one after the other, and the result would be exactly the same as the solutions outlined above.Thanks for all the help you two, it is much appreciated. Indeed flac.exe can accept multiple files. White spaces are the seperators, each file name wrapped in quotes if it contains spaces. File names are to be listed after flac.exe and some options. Code: [Select]flac [various options] "filename1" "filename2" "filename3" As to why I want to do this; flac supports something CALLED "replay gain" http://replaygain.hydrogenaudio.org/. Each file will be encoded separately, however flac.exe must know which files are considered an album/group to properly calculate replay gain values for each individual track. I think sidewinders idea/code of stringing the file names together should work. I don't fully understand what exactly the code is doing, but I will try it out and report back. Thanks again. -edit- grammaticalBased on your latest post, this will give you white space separators on the command line: Code: [Select]@echo off for %%x in (*.wav) do ( call set strCmd=%%strCmd%% "%%x" ) "g:\program files\flac\flac.exe" [various options] %strCmd% Be sure to put in the various options before running the code. The code is designed as a batch file. Simply reporting back as I said I would. The code does indeed work. Thanks again. |
|
| 8037. |
Solve : Use DOS from CMD prompt to show file version on WinXP PC? |
|
Answer» I am trying to display a file's name, last modified date, and file version from the command line. Maybe an approach from ASP.... I have over 10,000 files to get version info from so trying to do this programatically If you would like to do this with VBScript, this may help you out: Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") Set f = fso.GetFolder("c:\windows\system32") 'change directory name Set fc = f.Files For Each fs In fc If fso.GetExtensionName(fs) = "dll" then WScript.Echo fs.Name, fs.DateLastModified, fso.GetFileVersion(fs) End if Next Save script with a vbs extension and run from the command line as cscript scriptname.vbs You may want to make the OUTPUT more presentable.OMG... and to think I was just reading up on the WIndows FileVersion API FUNCTIONS and write a C Program for essentially that purpose. You saved me a lot of work Sidewinder! Sidewinder: Thanks for the help, that was exactly what I needed! I modifed the file like below to get a flat file output. Worked Great! Code: [Select]Option Explicit Dim fso, fc, f, fs Dim strPath, strFile 'On Error Resume Next strPath = "C:\Documents and Settings\profile\desktop\dlls.txt" Set fso = CreateObject("Scripting.FileSystemObject") Set strFile = fso.CreateTextFile(strPath, True) strFile.WriteLine("FileName,Last Modified,File Version") Set f = fso.GetFolder("C:\Documents and Settings\profile\dlldir") Set fc = f.Files For Each fs In fc If fso.GetExtensionName(fs) = "dll" then strFile.WriteLine(fs.Name & "," & fs.DateLastModified & "," & fso.GetFileVersion(fs)) End if Next |
|
| 8038. |
Solve : changing dos path using batch file? |
|
Answer» I am new to batch programming. I want the new window with path as c:\pqr\xyz. you can try following code Code: [Select]cd c:\pqr\xyz call cmd and for d:\abc\def you can try following code Code: [Select]d: cd abc\def call cmd may code solve ur problem |
|
| 8039. |
Solve : copy files in harddrive? |
|
Answer» My Windows XP is dead and I got to boot it in an external disc. I got to the screen of dos command. How can I copy those word/excel files in desktop and my document in my harddrive? |
|
| 8040. |
Solve : date manipulation within a batch file? |
|
Answer» Is there something available for date manipulation? E.G. I have a file aaa-bbb-20080930 which represents a file created on 20080930. I execute a PROCESS on 20081001 which needs the prior day's file which is aaa-bbb-20080930 . If I merely subtract 1 from today's date I'm not ending up with what I want in terms of the date part of the file I need to process. Getting yesterday's date is simple using a secondary language that has real time functions so we could for example create a one line vbs script which discovers yesterday's date and echoes it Code: [Select]wscript.echo (Date()- 1) and then CALL it from a batch file. It is probably simplest to create the vbs script within the batch file using echo and redirection, taking care to escape the parenthesis characters. I also see from the date format used in BRIANH's question that his local date format appears to be the US style, i.e. mm/dd/yyyy so I will assume that. Having got yesterday's date back from the vbscript it is necessary to remove the slashes and rearrange the digits to obtain the yyyymmdd format seen in the filename datestamp examples shown. Code: [Select]@echo off echo wscript.echo ^(Date^(^)- 1^)>yesterday.vbs for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a del yesterday.vbs set ydate1=%ydate1:/=% set m=%ydate1:~0,2% set d=%ydate1:~2,2% set y=%ydate1:~4,4% set ydate2=%y%%m%%d% echo yesterday was %ydate2% I wasn't saying you couldn't solve the problem- I thought you had simply- or, I should say- finally, lost patience to give it any of your time.Quote from: BC_Programmer on September 27, 2008, 11:27:06 AM I wasn't saying you couldn't solve the problem- I thought you had simply- or, I should say- finally, lost patience to give it any of your time. Oh ye of little faith.... I modified the code to suit my date format which is yyyy-mm-dd and it works fine except that if the current date is 2008-04-01 the new date is 2008-03-31 instead of 2008-03-29, where have I gone wrong please? Amended code Code: [Select]@echo off cls echo wscript.echo ^(Date^(^)- 1^)>yesterday.vbs for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a del yesterday.vbs set m=%ydate1:~5,2% set d=%ydate1:~-2% set y=%ydate1:~0,4% set ydate2=%y%-%m%-%d% echo yesterday was %ydate2% See below for how to make an absolute CHUMP of oneself Quote from: Hedonist on September 27, 2008, 05:03:46 PM I modified the code to suit my date format which is yyyy-mm-dd and it works fine except that if the current date is 2008-04-01 the new date is 2008-03-31 instead of 2008-03-29, where have I gone wrong please? The code is working fine. I suspect that "where you have gone wrong" is in confusing March and February. If "today" is the first day of the fourth month, that is, the first of April, then "yesterday" is the last day of March, which has thirty-one days (every year). If the current date were 2008-03-01 (The first of March, the third month of the year) then yesterday, since 2008 is a leap year, would be the twenty-ninth day of February, 2008-02-29. Here is a little rhyme which, if you learn it, may help you avoid this (evidently) tricky problem... Thirty days hath September, April, June, and November: All the rest have thirty-one, Except for February Which hath but twenty-eight days clear, And twenty-nine in each leap year. Quote I suspect that "where you have gone wrong" is in confusing March and February. No, 'twas nowt to do with that. I have discovered that when I awoke this a.m. I failed to switch on my brain before allowing fingers on keyboard. Thanks Dias, as usual a fine piece of coding. |
|
| 8041. |
Solve : compile and run both? |
|
Answer» hi friends, at commond line i type jrun javafile.java Change that to jrun javafile and let the batch file determine the file extensions. Check your path, if the java install did not add itself to your path, then a suggestion would be to LOGIN to the directory where your source code resides and use a path pointer to java directories. This will keep your source libraries and the java libraries separate. Code: [Select]@echo off cd C:\YourSourceDirectory C:\Program Files\Java\jdk1.6.0_02\bin\javac %1.java if not errorlevel 1 C:\Program Files\Java\jdk1.6.0_02\bin\java %1.class You will have to test this to make sure java can find all it's components. |
|
| 8042. |
Solve : Search and copy? |
|
Answer» What I'm trying to find, is a way to search for a string of text that's outputted from a command, then COPY the next couple characters, and finally store them as a variable. Computer name \\LAPTOP Next use the find command to extract the line where the GUID resides: net config rdr | find /i "tcpip" Quote NetBT_Tcpip_{96C2160D-9E3B-4AE5-97CC-4B88AE6DB75F} (001150F4851B) Next use the for command to parse the resulting output: for /f "tokens=3 delims={}_" %i in ('net config rdr | find /i "tcpip"') do echo GUID: %i Quote GUID: 96C2160D-9E3B-4AE5-97CC-4B88AE6DB75F Finally, fix up the command for use in a batch file. Code: [Select]@echo off for /f "tokens=3 delims={}_" %%i in ('net config rdr ^| find /i "tcpip"') do echo GUID: %%i The for command uses a combination of arbitrary tokens, delimiters, and a starting point of sequential addressable variables to do the parsing. For instance, this version of the for would be equally correct: Code: [Select]@echo off for /f "tokens=2 delims={}" %%x in ('net config rdr ^| find /i "netbt"') do echo GUID: %%x Hmm, I'm not 100% sure of what the "for /f" and the "tokens=3 delims={}_" are for. Furthermore the "%i" variable is contained within the "for" command, and cannot be used outside. Again, thanks for your THOROUGH REPLIES! |
|
| 8043. |
Solve : Calculating using time? |
|
Answer» I also have a calculating problem. |
|
| 8044. |
Solve : bat file processing a file with a date as part of the file name? |
|
Answer» I have a file aaa-bbb_yyyymmdd - yyyymmdd = current date. The file is really a logfile, created new each day at 12 AM with the current date as part of the file name. I have displayed the %DATE% variable in the BAT file and it You can use this notation for the current date: %date:/=% to strip out the slashes. Code: [Select]aaa-bbb_%date:/=% Good LUCK. Quote from: SIDEWINDER on September 25, 2008, 06:20:11 PM You can use this notation for the current date: %date:/=% to strip out the slashes. The notation WORKS like this %string:cat=dog% That MEANS: in %string% remove every occurrence of "cat" and put "dog" in its place. In the string variable whose name appears between the first percent sign and the colon, replace whatever is between the colon and the equals sign with whatever is between the equals sign and the right hand side percent sign. So %date:/=% replaces / with nothing, and %date:/=-% replaces / with a - (minus sign or hyphen). Many thanks.. that helped me a lot... Now, to ramp my issues up a notch... is there something available for date manipulation? E.G. I have a file aaa-bbb-20080930 which represents a file created on 20080930. I execute a process on 20081001 which needs the prior day's file which is aaa-bbb-20080930 . If I merely SUBTRACT 1 from today's date I'm not ending up with what I want... |
|
| 8045. |
Solve : Vista dos to rename? |
|
Answer» I had a crash with the computer. I have been able to get to command prompt and save most of my files using an xcopy command. I have a few files such as My Pictures that I get an error message when trying to COPY. I believe the reason is the space in the NAME. Is there a way to rename these files to copy or is there ANOTHER command to use instead of xcopy? Or is there any other means of saving these files? ThanksQuote I believe the reason is the space in the name Try putting QUOTES around the file names. ex: xcopy "c:\source" "c:\target" This seems to be working. I appreciate your reply very MUCH. I felt there must be a way I just didn't know what it was. Thank you so much. sp |
|
| 8046. |
Solve : I want to delete a file if the creation date is not current.? |
|
Answer» I have updated the configuration file for my software distribution solution. I want to delete the existing configuration file if the creation date is older than the newly created configuration file. I'm not sure whether you want to keep only the latest configuration, or remove a configuration set if it is superseded.Graham, Your suggestion would work perfectly if I was using a batch file to replace the current configuration file. My problem is that I have 22 subnets and a different configuration file for each subnet. A program runs during the LOGIN process and determines the 3rd octet of the PC. Then a configuration file is created on the PC based on the 3rd octet. The configuration file points the computer to a specific software distribution server. My objective is to delete the current configuration file. That will trigger the application to create a new configuration file. The new configuration file will have a new creation date. If the PC has a new configuration file, I don't want to delete it with my login script the next time my user logs into the PC. Hopefully you have more. I want to delete the configuration file if it is older than the date I specify in my batch file. Thank you for your response!!! ToddQuote from: Dias de verano on September 18, 2008, 11:56:20 AM Code: [Select]if not errorlevel==1 Días de verano, Gracias por su ayuda. This is the only way I know to get the date on the file. *** set todd=( DIR C:\NET\sus_client\wsus-*.reg) C:\Documents and Settings\THamblin>DIR C:\NET\sus_client\wsus-*.reg Volume in drive C has no label. Volume Serial Number is 680C-4B0F Directory of C:\NET\sus_client 12/04/2006 10:56 AM 2,010 wsus-cc.reg 1 File(s) 2,010 bytes 0 Dir(s) 11,905,589,248 bytes free C:\Documents and Settings\THamblin> *** Then I saw this in the forum and thought I could use it if I could set the date of the file as a variable. *** for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set hope= %%e/%%f/%%g *** I could get the right line of text with this. *** DIR C:\NET\sus_client\wsus-*.reg | FIND "/2006" *** But I have not found a way to pull the date out of that line of text. Any ideas you can come up with would be appreciated. Thanks, ToddI'll be the first to admit that this is a mess, but it seems to work. You're only checking for equality, which is a simple string compare. There is no real need to fix up the dates into yyyymmdd format. Code: [Select]@echo off for /f "tokens=2 delims= " %%i in ("%date%") do ( set dt=%%i ) for /f "skip=5 tokens=1,7 delims=/ " %%i in ('dir /a-d C:\NET\sus_client\wsus-*.reg') do ( if %dt% NEQ %%i echo del C:\NET\sus_client\%%~nxj 2>nul ) As written, the script will simply list the files to be deleted. When you are satisfied with the RESULT, remove the WORD echo from the next to last line. Good luck. To get the various dates possibly associated with a file you can use dir with the /T switch and one of these letters: C Creation A Last Access W Last Written Thus DIR /TC gets creation date / time so: Code: [Select]@echo off REM assumes there is only ONE .reg file in the folder for /f %%A ('dir /b /TC C:\NET\sus_client\wsus-*.reg') do set Cdatetime=%%~tA for /f "tokens=1,2 delims= " %%D in ("%Cdatetime%") do set Cdate=%%D echo creation date: %cdate% echo today's date: %date% if not "%cdate%"=="%date%" goto nochange REM code to run if dates are different :nochange I am a bit confused because in the first post, I see this Quote from: THamblin I want to delete the existing configuration file if the creation date is older than the newly created configuration file. But now I see the requirement has changed to deleting the existing configuration file if the the creation date is just different from the newly created one. Thank you Sidewinder and Días de verano. Your ideas have helped me to get my solution. You are both AWESOME!!! Thanks, Todd |
|
| 8047. |
Solve : How to run my personal exe file during boot up?? |
|
Answer» Quote from: getkiran1 on SEPTEMBER 25, 2008, 04:17:49 AM NB: my INTENTION was not to hack or somthng lik dat.. jst for gaining knowledge.. ok? Ok, whatever you SAY. |
|
| 8048. |
Solve : batch file - multiple lines in one? |
|
Answer» Hi, I have been looking for a way to do the following : |
|
| 8049. |
Solve : Recycling an Application Pool (IIS 6.0)? |
|
Answer» Hello everyone, |
|
| 8050. |
Solve : Batch file to read a text file? |
|
Answer» Hi, |
|