Explore topic-wise InterviewSolutions in Microsoft.

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your Microsoft knowledge and support exam preparation. Choose a topic below to get started.

8801.

Solve : Unfamiliar with use of the @ sign at the end of a statement?

Answer» <html><body><p>In a DOS batch <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a> I am trying to understand, I have found a statement which uses the "@" sign in a way I am not familiar with. I have look in several places and my books, but I have not found an explanation. The statement is:<br/><br/>type {file name}\<a href="/cdn-cgi/l/email-protection">[emailprotected]</a><br/><br/>Where {file name} is a legitimate file name and temp is a legitimate sub file name<br/><br/>Does anyone know what the "@8" does.<br/><br/>I am familiar with <a href="https://interviewquestions.tuteehub.com/tag/using-1441597" style="font-weight:bold;" target="_blank" title="Click to know more about USING">USING</a> the "@" sign to suppress printing of a statement such as "@echo" to suppress the printing of "echo".<br/><br/>Thanks for any help,<br/><br/>Tom<br/>It is a unit of measure<br/><a href="https://en.wikipedia.org/wiki/Arroba">http://en.wikipedia.org/wiki/Arroba</a><br/>It is also used in accounting.<br/><a href="https://en.wikipedia.org/wiki/At_sign">http://en.wikipedia.org/wiki/At_sign</a><br/><br/>Also:<br/>Quote</p><blockquote>In Perl, @ prefixes variables which <a href="https://interviewquestions.tuteehub.com/tag/contain-409810" style="font-weight:bold;" target="_blank" title="Click to know more about CONTAIN">CONTAIN</a> arrays.<br/>In Pascal, @ is the "address of" operator<br/>In Welsh, it is sometimes known as a malwen or malwoden (a snail).<br/><br/>[ @ ] (Asperand or At) This sign is used in batch files to prevent the text following it on the same line from being displayed on the screen. An example is "ECHO OFF". It is used at the start of most batch files to turn off screen echoing (displaying) for all lines following. Employing `@' with it as "@ECHO OFF", will prevent this Asperand and the words "Echo Off" from appearing on screen.<br/><br/> As well as the above, `@' is used by 4DOS to designate variable <a href="https://interviewquestions.tuteehub.com/tag/functions-13351" style="font-weight:bold;" target="_blank" title="Click to know more about FUNCTIONS">FUNCTIONS</a>. "@FILEDATE" will return a file's date, as an example.<br/><br/>Finally, the `@ sign is employed to designate file lists in many versions of DOS. "DEL @FILENAME.lst" means that DOS will delete the files listed in "FILENAME.lst". <br/></blockquote><br/>But @8 is note known here.<br/>It's not used. "{file name}" is a directory. "<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>" is a file.Thanks for the quick replies.<br/><br/>It was used as a file name. <a href="https://interviewquestions.tuteehub.com/tag/searching-1197083" style="font-weight:bold;" target="_blank" title="Click to know more about SEARCHING">SEARCHING</a> deep into the referenced program I found several folders with file names such as @1, @2, @3,....<br/><br/>Tom</body></html>
8802.

Solve : How to move a full folder??

Answer» <html><body><p>So, i have a big folder with other folders and files inside it. <br/>Whats the Batch command to move it to another location?I would do this, but there may be a better way. As far as I know the move command doesn't work for a directory tree.<br/><br/>Code: <a>[Select]</a>XCOPY "[source folder here]" "[destination folder]" /E /C /R /I /<a href="https://interviewquestions.tuteehub.com/tag/k-236601" style="font-weight:bold;" target="_blank" title="Click to know more about K">K</a> /Y<br/>RD "[source folder]"<br/><a href="https://interviewquestions.tuteehub.com/tag/moving-548882" style="font-weight:bold;" target="_blank" title="Click to know more about MOVING">MOVING</a> large Trees with DOS is not a very <a href="https://interviewquestions.tuteehub.com/tag/good-1009017" style="font-weight:bold;" target="_blank" title="Click to know more about GOOD">GOOD</a> idea. <br/>The likelihood of error is rather high. <br/>Files may be in use or marked as read-only which will cause errors.<br/><br/>First copy, then if no errors, remove original files and folders. Better yet, use a program made to do this kind of work. Windows has a application <a href="https://interviewquestions.tuteehub.com/tag/call-412416" style="font-weight:bold;" target="_blank" title="Click to know more about CALL">CALL</a> 'Sync Toy' that could be used.<br/><br/>Quote</p><blockquote><a href="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=c26efa36-98e0-4ee9-a7c5-98d0592d8c52">SyncToy 2.1</a><br/>Brief Description<br/>SyncToy 2.1 is a free application that synchronizes files and folders between locations. Typical uses include sharing files, such as photos, with other computers and <a href="https://interviewquestions.tuteehub.com/tag/creating-427346" style="font-weight:bold;" target="_blank" title="Click to know more about CREATING">CREATING</a> backup copies of files and folders</blockquote><br/>Quote<blockquote>Files may be in use or marked as read-only which will cause errors.</blockquote><br/>The /E /C /R /I /K /Y should take care of that. As for the being in use, it would behave the same way in GUI, right?Quote from: Linux711 on April 30, 2011, 02:03:36 PM<blockquote>The /E /C /R /I /K /Y should take care of that. As for the being in use, it would behave the same way in GUI, right?<br/></blockquote>No. It depends. But you can use Robocopy<br/>Quote<blockquote>While still included in Windows Vista, Xcopy has been deprecated in favor of Robocopy, a much more powerful copy tool, which is now built into the operating system.<br/></blockquote><a href="https://en.wikipedia.org/wiki/Robocopy">http://en.wikipedia.org/wiki/Robocopy</a><br/></body></html>
8803.

Solve : Using BATCH file: Find a number inside a file and increment it?

Answer» <html><body><p>Quote from: Allan on May 01, <a href="https://interviewquestions.tuteehub.com/tag/2011-290379" style="font-weight:bold;" target="_blank" title="Click to know more about 2011">2011</a>, 02:47:25 PM</p><blockquote>It is what it is. <a href="https://interviewquestions.tuteehub.com/tag/let-11597" style="font-weight:bold;" target="_blank" title="Click to know more about LET">LET</a>'s stay with the thread please. Thanks.<br/></blockquote><br/>Essentially, this thread is now complete. The OP expressed a requirement which was clarified and then addressed, despite frequent attempts at <a href="https://interviewquestions.tuteehub.com/tag/interference-1048167" style="font-weight:bold;" target="_blank" title="Click to know more about INTERFERENCE">INTERFERENCE</a>, to the OP's expressed <a href="https://interviewquestions.tuteehub.com/tag/satisfaction-1195186" style="font-weight:bold;" target="_blank" title="Click to know more about SATISFACTION">SATISFACTION</a>. <br/>Okay Thanks. I'll <a href="https://interviewquestions.tuteehub.com/tag/lock-1077406" style="font-weight:bold;" target="_blank" title="Click to know more about LOCK">LOCK</a> it then.</body></html>
8804.

Solve : Add Created Date to Current Word File Name?

Answer» <html><body><p>Hi,<br/><br/>I've never used DOS before but figure it's the only way to <a href="https://interviewquestions.tuteehub.com/tag/rename-613846" style="font-weight:bold;" target="_blank" title="Click to know more about RENAME">RENAME</a> hundreds of already saved word documents with the current filename and the created date appended to the end.<br/><br/>In work they want the following format (filename = xxxxxxxxxx_YYYYMMDD). Can anyone help as I have been going through them picking out duplicate documents and adding the created date one at a time. It's <a href="https://interviewquestions.tuteehub.com/tag/driving-959784" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVING">DRIVING</a> me mad.<br/><br/>Many thanks,<br/><br/>Jo We need to know your local date format <a href="https://interviewquestions.tuteehub.com/tag/settings-771535" style="font-weight:bold;" target="_blank" title="Click to know more about SETTINGS">SETTINGS</a>. How do file dates show up in DIR listings?<br/><br/>If they are Word documents do you still need the .doc extension for example like this?<br/><br/>xxxxxxxxxx_YYYYMMDD.doc<br/>Thanks for replying. I'm not sure how to tell what format anything is in with DOS. It's a work computer and I won't be in there until tomorrow morning. I'm in the UK sorry. Is there anything else I need to find out while on the computer tomorrow?<br/><br/>Many thanks,I'm in the UK too. If the computer system has the UK date setting then, when you open a command prompt and type DIR the result should look like this<br/><br/><br/>D:\&gt;dir<br/>Volume in drive D is SATA2<br/>Volume Serial Number is E8B2-C5D7<br/><br/>Directory of D:\<br/><br/>17/04/2011 13:18 &lt;DIR&gt; $RECYCLE.BIN<br/>22/07/2011 20:01 1,010,592 -list.csv<br/>16/04/2011 21:14 &lt;DIR&gt; Audio-DL<br/>16/02/2011 21:33 &lt;DIR&gt; Camera Videos<br/>14/07/2011 17:49 &lt;DIR&gt; Cinema<br/>24/07/2011 19:56 &lt;DIR&gt; DVD-Author<br/>04/06/2011 11:18 &lt;DIR&gt; F-Root<br/>13/02/2011 14:03 2,308 fraglist.luar<br/>13/02/2011 14:03 2,388 fraglist.txt<br/>09/07/2011 14:39 &lt;DIR&gt; Music<br/>26/06/2011 12:21 &lt;DIR&gt; OS-Install<br/>10/07/2011 19:41 &lt;DIR&gt; Railways<br/>09/07/2011 00:07 &lt;DIR&gt; Tempvu<br/>17/07/2011 21:16 &lt;DIR&gt; TV<br/>17/07/2011 15:21 &lt;DIR&gt; Virtual Machines<br/>12/11/2010 19:57 &lt;DIR&gt; wallpaper<br/>22/05/2011 11:29 &lt;DIR&gt; Webspace<br/>04/06/2011 11:19 &lt;DIR&gt; WindowsImageBackup<br/> 3 File(s) 1,015,288 bytes<br/> 15 Dir(s) 204,722,483,200 bytes free<br/><br/><br/>That is, the file date is given in the form dd/mm/yyyy<br/><br/><br/><br/><br/>Code: <a>[Select]</a>@echo off<br/>rem Assume your %date% format is mm/dd/yyyy<br/>for %%a in (*.doc) do (<br/> ren "%%a" "%%~na_%date:~6,4%%date:~0,2%%date:~3,2%.doc"<br/>)Quote from: CN-DOS on August 14, 2011, 07:08:28 AM</p><blockquote>rem Assume your %date% format is mm/dd/yyyy<br/></blockquote><br/>Why?<br/><br/>Oooooooops, in case OP doesn't know how to get create data.<br/>Code: <a>[Select]</a>@echo off<br/>rem Assume your %date% format is mm/dd/yyyy<br/>for %%a in (*.doc) do (<br/> call :CreateTime "%%a"<br/>)<br/>goto :<a href="https://interviewquestions.tuteehub.com/tag/eof-446162" style="font-weight:bold;" target="_blank" title="Click to know more about EOF">EOF</a><br/><br/>:CreateTime<br/>setlocal enabledelayedexpansion<br/>for /f "skip=5" %%b in ('dir /tc %1') do (<br/> set ct=%%b<br/> ren %1 "%~n1_!ct:~6,4!!ct:~0,2!!ct:~3,2!.doc"<br/> goto :eof<br/>)<br/>endlocalhi jaynelson,<br/><br/>Did you tried a filename with blank space? Like "<a href="https://interviewquestions.tuteehub.com/tag/hello-484176" style="font-weight:bold;" target="_blank" title="Click to know more about HELLO">HELLO</a> world.doc"</body></html>
8805.

Solve : python script?

Answer» <html><body><p>Hi <br/>I don’t know anything about programming languages. I’m trying to run a python script from the command line (./proc.py) and I get the following <a href="https://interviewquestions.tuteehub.com/tag/message-25597" style="font-weight:bold;" target="_blank" title="Click to know more about MESSAGE">MESSAGE</a> “./proc.py is not recognized as an internal or external command, operable program or batch file. What should I do? <br/>Quote from: belen on May 02, 2011, 08:41:03 AM</p><blockquote>Hi <br/>I don’t know anything about programming languages. I’m trying to run a python script from the command line (./proc.py) and I get the following message “./proc.py is not recognized as an internal or external command, operable program or batch file. What should I do?<br/></blockquote>The command<br/>./proc.py<br/>will not work from the command line. It is not part of the set or programs or commands that *DOS knows about. A script has to be run from its interpreter.This rule applies not only to Python, but all scripting languages.<br/>A Python interpreter suitable for DOS can be found at:<br/><a href="https://www.python.org/">http://www.python.org/</a><br/>The <a href="https://interviewquestions.tuteehub.com/tag/current-240611" style="font-weight:bold;" target="_blank" title="Click to know more about CURRENT">CURRENT</a> production versions are Python 2.7.1 and Python 3.2.<br/><br/>Once you have a suitable version installed on your PC, you can <a href="https://interviewquestions.tuteehub.com/tag/invoke-519070" style="font-weight:bold;" target="_blank" title="Click to know more about INVOKE">INVOKE</a> Python from the command line and pass the script as an argument. <a href="https://interviewquestions.tuteehub.com/tag/see-630247" style="font-weight:bold;" target="_blank" title="Click to know more about SEE">SEE</a> the documentation for <a href="https://interviewquestions.tuteehub.com/tag/examples-251225" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLES">EXAMPLES</a>.<br/>--------<br/>*DOS, I mean the command line in Windows. Everybody calls it DOS and the documentation is found under DOS on this forum.<br/>Screen Shot of shell.<br/></body></html>
8806.

Solve : How to create a loop??

Answer» <html><body><p>Hi,<br/><br/>I was wondering if someone can help me create a loop in a batch file? What I'm doing is creating a batch file that will build a SQl 2005 DB from scripts. I've got the SQL scripts in a folder on the C drive. <br/><br/>I've created a batch file that will look in the directory with the scripts and put the list of names of the SQL files in a cmd file called myfile.cmd. i.e.<br/><br/>ADR.sql<br/>ADTC.sql<br/>BedMap.sql<br/>Community.sql<br/><br/>The script then uses that myfile.cmd to make a new cmd file with the SQLCMD appended to the SQL script name to execute and create the DB. So what you <a href="https://interviewquestions.tuteehub.com/tag/get-11812" style="font-weight:bold;" target="_blank" title="Click to know more about GET">GET</a> is if you have 30 SQL scripts in the folder on C drive the cmd file will have 30 lines in it to build the DB. i.e.<br/><br/>SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\ADR.sql -o C:\Logs\NightlyLog.txt <br/>SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\ADTC.sql -o C:\Logs\NightlyLog.txt <br/>SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\BedMap.sql -o C:\Logs\NightlyLog.txt <br/>SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\Community.sql -o C:\Logs\NightlyLog.txt<br/>...<a href="https://interviewquestions.tuteehub.com/tag/etc-251218" style="font-weight:bold;" target="_blank" title="Click to know more about ETC">ETC</a>,etc..<br/><br/>This works! except I can't get it to log the output. It will log the output but only if there is just one line in the cmd file. <br/><br/>I was thinking the logging might work if I can loop through the SQL script names one line at a time instead of having them all in one cmd file. <br/><br/>Can anyone help me figure out how to loop through the SQL scripts? Here is a sample of the batch file I've created. That will build the DB but won't log if ther eis an error.<br/><br/>@echo off<br/>REM<br/>REM Create the command file with the names of all the SQl scripts<br/>REM<br/><br/><br/>dir C:\Vault\Dev\DW\Database\Schema /b &gt;C:\Nightlybuild\Loggingtest\myfile.cmd<br/><br/><br/>REM<br/>REM Add the SQLCMD to the beginning of each line<br/>REM <br/><br/><br/><br/>for /F "delims=" %%j in (myfile.cmd) do echo.SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\%%j -o C:\Logs\NightlyLog.txt &gt;&gt; BuildSchema.cmd <br/><br/><br/>REM<br/>REM Delete the myfile.cmd<br/>REM<br/><br/>DEL C:\Nightlybuild\Loggingtest\myfile.cmd<br/><br/><br/>@exit<br/>Code: <a>[Select]</a>@echo off<br/>echo. &gt; BuildSchema.txt<br/>for /F "delims=" %%j in (myfile2.txt) do (<br/>echo %%j<br/>)<br/>echo.<br/>for /F "delims=" %%j in (myfile2.txt) do (<br/><br/>echo."SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\%%j -o C:\Logs\NightlyLog.txt" &gt;&gt; BuildSchema.txt<br/>)<br/>type BuildSchema.txt<br/><br/><br/>Out:<br/><br/>C:&gt;loophow.bat<br/>ADR.sql<br/>ADTC.sql<br/>BedMap.sql<br/>Community.sql<br/><br/><br/>"SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\ADR.sql -o C:\Logs\NightlyLog.txt"<br/>"SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\ADTC.sql -o C:\Logs\NightlyLog.txt"<br/>"SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\BedMap.sql -o C:\Logs\NightlyLog.txt"<br/>"SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\Community.sql -o C:\Logs\NightlyLog.txt"<br/><br/>C:&gt;Code: <a>[Select]</a>@echo off<br/>&gt;BuildSchema.cmd set /p =SQLCMD -d DBName &lt;nul<br/>for /f "delims=" %%j in ('dir /b C:\Vault\Dev\DW\Database\Schema\*.sql') do (<br/> &gt;&gt;BuildSchema.cmd set /p =-i C:\Vault\Dev\DW\Database\Schema\%%j &lt;nul<br/>)<br/>&gt;&gt;BuildSchema.cmd echo -o C:\Logs\NightlyLog.txtThanks CN-DOS and DanCollins for the <a href="https://interviewquestions.tuteehub.com/tag/response-771382" style="font-weight:bold;" target="_blank" title="Click to know more about RESPONSE">RESPONSE</a>. CN-DOS I used yours it worked great!<br/>There was one down fall. There are some 500+ tables to create and the script was well over 256 characters to make the tables so it fails. I'll have to look for a way to cut it upI notice in your first post that all the <strong>sqlcmd</strong> executions output to the same log file. How does that work? Does each new log <a href="https://interviewquestions.tuteehub.com/tag/overwrite-7260962" style="font-weight:bold;" target="_blank" title="Click to know more about OVERWRITE">OVERWRITE</a> or append to the existing log?<br/><br/>This is just a thought, but make each log name unique. You can always concatenate the logs into a single file later.<br/><br/>Try writing the <strong>for</strong> loop as:<br/><br/>Code: <a>[Select]</a>for /F "delims=" %%j in (myfile.cmd) do (<br/> set/a count+=1<br/> echo.SQLCMD -d DBName -i C:\Vault\Dev\DW\Database\Schema\%%j -o C:\Logs\NightlyLog!count!.txt &gt;&gt; BuildSchema.cmd<br/>) <br/><br/>Be sure to insert <strong>setlocal enabledelayedexpansion</strong> as the second line in your batch file (directly after <strong>@echo off</strong>)<br/><br/>Who knows, it might actually work.</p></body></html>
8807.

Solve : Batch for create a copy of the original file from a shortcut file.?

Answer» <html><body><p>Batch for create a copy of the original file from a shortcut file.<br/><br/>A Shortcut is a pointer to the original file.<br/><br/>I would like a batch for select the shortcut file to transform in a copy of the original file. <br/><br/>Best Regards<br/>Just curious as to why not use the full path with a regular copy or xcopy statement? Which shortcut would be dynamic in which you would want to use a shortcut with an <a href="https://interviewquestions.tuteehub.com/tag/unknown-1438723" style="font-weight:bold;" target="_blank" title="Click to know more about UNKNOWN">UNKNOWN</a> path, but a preset name?What I am trying is : <br/><br/>I have a shortcut file pointing to his original file.<br/>A Shortcut is a pointer to the original file.<br/><br/>I would like to make a copy of the original file in the folder where the shorcut is, and then delete optionally the shortcut.<br/><br/>Where can I find this script ?Quote</p><blockquote>I have a shortcut file pointing to <strong>his</strong> original file</blockquote><br/>If its not YOUR file then you are doing this over a network? With a shared path to HIS file which just happens to be a shortcut?<br/><br/>Guessing this is a remote system on a network <a href="https://interviewquestions.tuteehub.com/tag/since-644476" style="font-weight:bold;" target="_blank" title="Click to know more about SINCE">SINCE</a> if you just wanted to make an exact copy of a file you could do it through windows locally. Also guessing that this is not a one time copy since you could simply double-click on the shortcut to navigate to the file and get a copy that way if it was a 1 time copy.<br/><br/>If you right-click your shortcut you can select properties, and then view the target path. Then select that target path and use that target path in a batch file such as <br/><br/>xcopy shortcut_target_path\file_you_want.* c:\drop_file_here\*.* /s/d/y<br/><br/>Replace shortcut_target_path with the target path that you got from your shortcut. If there are any spaces in the path you will need to <a href="https://interviewquestions.tuteehub.com/tag/bind-897680" style="font-weight:bold;" target="_blank" title="Click to know more about BIND">BIND</a> it with " ". Also if you are using Windows Vista or <a href="https://interviewquestions.tuteehub.com/tag/7-240263" style="font-weight:bold;" target="_blank" title="Click to know more about 7">7</a>, you will want to use robocopy instead of xcopy with different switches.<br/><br/>Trying to push a shortcut.lnk into a batch is just going to be nothing but trouble. If you declare the <a href="https://interviewquestions.tuteehub.com/tag/unc-2315341" style="font-weight:bold;" target="_blank" title="Click to know more about UNC">UNC</a> path directly, you will be better off. <a href="http://www.uwplatt.edu/oit/terms/uncpath.html">http://www.uwplatt.edu/oit/terms/uncpath.html</a><br/><br/>If you run into a UNC path issue, you can always create a mapped drive to the folder location where that file resides such as X: Then use xcopy x:\file_you_want.* c:\drop_file_here\*.* /s/d/y or the robocopy equivilant if Vista or 7 at your end. And you have to bind the origin target path with " " if there are spaces.It's done Dave. In autohotkey. <br/>I hope the next time will be more simple. <br/>Really I am afraid. <br/><br/>Best Regards<br/></body></html>
8808.

Solve : Batch command help?

Answer» <html><body><p>Hello gurus!<br/><br/>I would like to ask your help on my problem. <br/>I have an application that is residing on my c:\program files\my application\app-cmd<br/>I need to run this, using command line and need to add some syntax before it runs. my syntax if im doing it manually, I will run this in command line c:\program files\my application\app-cmd -a -b -c seriousman.xml <br/><br/>I need to do this every hour in an XP machine.<br/><br/>I would really appreciate your help on this.<br/>Thank you in advance and more power!<br/><br/>If you having Task Scheduler <a href="https://interviewquestions.tuteehub.com/tag/service-239469" style="font-weight:bold;" target="_blank" title="Click to know more about SERVICE">SERVICE</a> enabled in your system, try this one:<br/><br/>Code: <a>[Select]</a>schtasks /create /<a href="https://interviewquestions.tuteehub.com/tag/ru-1191895" style="font-weight:bold;" target="_blank" title="Click to know more about RU">RU</a> %username% /sc <a href="https://interviewquestions.tuteehub.com/tag/hourly-2716373" style="font-weight:bold;" target="_blank" title="Click to know more about HOURLY">HOURLY</a> /mo <a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a> /tn MyTest /tr "cmd /c c:\program files\my application\app-cmd -a -b -c seriousman.xml"Thank you.<br/><br/>But I'm receiving this error...<br/><br/>ERROR: No mapping between account names and security IDs was done.<br/><br/>anything wrong in my <a href="https://interviewquestions.tuteehub.com/tag/environment-15858" style="font-weight:bold;" target="_blank" title="Click to know more about ENVIRONMENT">ENVIRONMENT</a>?<br/><br/>How about this one?<br/>Code: <a>[Select]</a>schtasks /create /ru System /sc hourly /mo 1 /tn MyTest /tr "cmd /c c:\program files\my application\app-cmd -a -b -c seriousman.xml"</p></body></html>
8809.

Solve : Are there any such CMD commands to reset BIOS??

Answer» <html><body><p>Are there any such CMD <a href="https://interviewquestions.tuteehub.com/tag/commands-18925" style="font-weight:bold;" target="_blank" title="Click to know more about COMMANDS">COMMANDS</a> to reset the BIOS <a href="https://interviewquestions.tuteehub.com/tag/back-389278" style="font-weight:bold;" target="_blank" title="Click to know more about BACK">BACK</a> to default settings including <a href="https://interviewquestions.tuteehub.com/tag/changing-246341" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGING">CHANGING</a> the USB Legacy from disabled to enabled, or do I need MS-DOS? Does the CMD even have full control over the BIOS without a PS/2 keyboard?Back to default can be usually done by jumper setting on main board or removing the cmos battery and then replacing teh cmos battery after a few minutes for the cmos to lose its settings and default to default. Some bios's also have a feature to select to set all settings back to default.<br/><br/>Only interaction with bios from command prompt would require addressing it with another program such as a flash utility etc. Some are <a href="https://interviewquestions.tuteehub.com/tag/bootable-7665304" style="font-weight:bold;" target="_blank" title="Click to know more about BOOTABLE">BOOTABLE</a> floppy utilities which are not really dos and others can be run from DOS or Windows environment.I can't reset it in the BIOS because I disabled USB which means I need a PS/2 keyboard.<br/><br/>What bootable DOS tools are you referring to that can reset it?I'd go with the method of removing cmos battery. Its about the size of a quarter in a desktop computer. Do this with power cable unplugged in case battery pops out and lands on chip legs etc. Then wait a few minutes and then insert the battery back in the correct way. Then reconnect power cable andyou should be back to default.<br/><br/><strong>This will set it back to default.</strong><br/><br/>Some systems have a jumper to use or push button to reset, but if you go messing with jumpers you could mess stuff up badly, so battery removal and reinsertion is <a href="https://interviewquestions.tuteehub.com/tag/probably-1167177" style="font-weight:bold;" target="_blank" title="Click to know more about PROBABLY">PROBABLY</a> safest method for you.<br/>Yes there are.<br/><a href="https://www.wikihow.com/Reset-Your-BIOS">http://www.wikihow.com/Reset-Your-BIOS</a><br/><br/><br/>the CMD debug part has worked for me.Code: <a>[Select]</a>@echo off<br/>set dbgFile=%temp%\dbgTmp.txt<br/>&gt;"%dbgFile%" echo o 70 10<br/>&gt;&gt;"%dbgFile%" echo o 71 01<br/>&gt;&gt;"%dbgFile%" echo q<br/>debug&lt;"%dbgFile%"</p></body></html>
8810.

Solve : run 2nd and 3rd bat file 5 min after running 1st bat file?

Answer» <html><body><p>Hi<br/><br/>I have four bat file (Win XP cmd)<br/><br/>1. Del<br/>2. FBHI<br/>3. HFI<br/><a href="https://interviewquestions.tuteehub.com/tag/4-238406" style="font-weight:bold;" target="_blank" title="Click to know more about 4">4</a>. min5ha<br/><br/>Problem 1:<br/><strong>del </strong>run automatically each morning as I log in. I combined them into one, when I run it run [del] then [FBHI] then closed. Do not run other two. <br/><br/>Problem 2: <br/>#2, 3, 4 takes about 25min each to create 168maps as jpeg, where I do not want to wait to finish [FBHI] then run 3 and 4. <a href="https://interviewquestions.tuteehub.com/tag/however-at-491999" style="font-weight:bold;" target="_blank" title="Click to know more about HOWEVER">HOWEVER</a> I would like to wait for 5 min after [FBHI] started and then run other two. <br/><br/>Is there any way to do it in Win XP cmd. <br/><br/>Thanks if you have any solve for this. <br/><br/>saahmadbulbl<br/>maybe you can add a <a href="https://interviewquestions.tuteehub.com/tag/timeout-710029" style="font-weight:bold;" target="_blank" title="Click to know more about TIMEOUT">TIMEOUT</a>, if it exist on xp.How?add<br/>timeout 300<br/>call 2ndprogrem.battime out dosent exist in xp so use the ping trick <br/>ping localhost -n 301 &gt;nuLQuote from: SATexas on April 17, 2011, 05:13:56 PM</p><blockquote>C:\test&gt;type mainbat.bat<br/>@echo off<br/><br/>call delbat.bat<br/>echo return from delbat.bat<br/>call FBHI.bat<br/>echo return from FBHI.bat<br/>echo Use sleep command for delays<br/>rem sleep 300<br/>sleep 25<br/>call HFI.bat<br/>echo return to main from HFI<br/>call min5ha.bat<br/>echo return to main from min5ha.bat<br/><br/>echo The End<br/>echo BYE<br/><br/></blockquote><br/>Dear SATexas<br/>Thank you very <a href="https://interviewquestions.tuteehub.com/tag/much-249971" style="font-weight:bold;" target="_blank" title="Click to know more about MUCH">MUCH</a> for your help. I modified your codes to the followings but it seems like it is not working. <br/><br/>After running FBHI for 1700 second the program closed itself and did not started HFI.bat or min5ha.bat or VI.bat. Did I missed anything in the code?<br/><br/>I don't mind if they (HFI, min5ha and VI) <a href="https://interviewquestions.tuteehub.com/tag/start-239994" style="font-weight:bold;" target="_blank" title="Click to know more about START">START</a> one after one after 60 second in different command window. <br/><br/>Thank you very much<br/><br/>***********. <br/>@echo off<br/><br/>call del.bat<br/>echo return from delbat.bat<br/>call FBHI.bat<br/>echo return from FBHI.bat<br/>echo Use sleep command for delays<br/>rem sleep 60<br/>sleep 25<br/>call HFI.bat<br/>echo return to main from HFI<br/>call min5ha.bat<br/>echo return to main from min5ha.bat<br/>call VI.bat<br/>echo return to main from VI.bat<br/>echo The End<br/>echo BYE<br/>*********Still not working !!</body></html>
8811.

Solve : Copy files to ddmmyyyy folder?

Answer» <html><body><p>Hi<br/>want to copy 3 Folders with 168 jpeg files each <br/><br/>C:\Firemod\temp<br/><br/>to <br/><br/>B:\Projects\Fire Behaviour Outputs\Hourly output\ddmmyyyy<br/><br/>where this folder has created using the following codes<br/><br/>** codes**<br/>=======================================================<br/>@echo off<br/>echo D = Now : WScript.Echo Right(100+Month(D),2) _ &gt;%temp%\today.vbs<br/>echo ^&amp; Right(100+Day(D),2) ^&amp; Right(Year(D),4) &gt;&gt;%temp%\today.vbs<br/><br/>for /f "tokens=1" %%a in (<br/>'cscript.exe //Nologo %temp%\today.vbs') do set today=%%a<br/><br/>del %temp%\today.vbs<br/><br/>echo Hi <br/><br/>echo saahmadbulbul, Todays date is : %today%<br/>md %today%<br/><br/>echo Created a folder for you; it is in B:\Projects\Fire Behaviour Outputs\Hourly output as todays date<br/><br/>=======================================================<br/><br/>each day file name will change and I need to copy those files as a regular basis. <br/><br/>I do not have programming skill to write complex code. Does anyone knows how to do it in winXP cmd? <br/><br/><br/>Thanks a lot if you can solve this problem. <br/><br/><br/>saahmadbulbul <br/><br/>I also was trying to create a folder with the name as the <a href="https://interviewquestions.tuteehub.com/tag/current-240611" style="font-weight:bold;" target="_blank" title="Click to know more about CURRENT">CURRENT</a> date. I found an article on this website <a href="https://interviewquestions.tuteehub.com/tag/titled-1420936" style="font-weight:bold;" target="_blank" title="Click to know more about TITLED">TITLED</a> "How can I make a batch file rename a file to the date or time?" I used that information to create the folder. Here's what works for me:<br/>for /f "tokens=1-5 delims=/ " %%d in ("%date%") do md B:\Projects\Fire Behaviour Outputs\Hourly output %%g-%%e-%%f<br/>I used the path you had in your post in the string above. This will create a folder with the name YYYY-MM-DD (example 2011-03-28). In the original article I read they had the date as MM-DD-YYYY, but I prefer the year-month-day instead because if I have many folders, it's <a href="https://interviewquestions.tuteehub.com/tag/easier-447966" style="font-weight:bold;" target="_blank" title="Click to know more about EASIER">EASIER</a> to sort them chronologically. The tokens for the date are %%e=month, %%f=day, &amp; %%g=year. And if you want to add the day of the week, add %%d.<br/>I created the following "for /f "tokens=1-5 delims=/ " %%d in ("%date%") do md c:\users\bonz\bat\%%d-%%g-%%e-%%f", and the resulting folder name is "Mon-2011-03-28"<br/>Another thing. I noticed you are creating the folder in drive B. If this is a removable disk (floppy), you might want the bat file to check and make sure there is a disk in the drive. Such as if not exist b:\*.* echo THERE IS NO DISK IN DRIVE B.Thank you [BonzCXL] for your help<br/>But fixed date time now the code is <br/><br/>========================<br/><br/>cd B:\Projects\Fire Behaviour Outputs\Hourly output<br/>B:<br/><br/>@echo off<br/>echo D = Now : WScript.Echo Right(Year(D),4) _ &gt;%temp%\today.vbs<br/>echo ^&amp; Right(100+Month(D),2) ^&amp; Right(100+Day(D),2) &gt;&gt;%temp%\today.vbs<br/>/f "tokens=1" %%a in (<br/>'cscript.exe //Nologo %temp%\today.vbs') do set today=%%a<br/><br/>del %temp%\today.vbs<br/><br/>echo Hi <br/><br/>echo saahmadbulbul, Todays date is : %today%<br/>md %today%<br/><br/>echo A folder has created for you; it is in ** B:\Projects\Fire Behaviour Outputs\Hourly output as todays date <br/><br/>==========================<br/><br/><br/><br/><strong>but my main problem is to copy files to that folder. </strong> not it is yyyymmyy format<br/><br/><br/>Thanks if you have any help ?Thanks [donlong88] for helping me with the codes. <br/><br/>Now i created 2 bat files to copy the files to two different network drives B: and R:<br/><br/>I would like to know I can combine those two bat files into one. I wrote <br/><br/>@echo off<br/>copy2B.bat<br/>copy2R.bat<br/><br/>but did not work. <br/><br/><br/>Thanks<br/><br/>Here are the codes for copy2B.bat and copy2R.bat<br/>**************************************** <br/><br/>copy2B<br/>======<br/>@echo off<br/>CD\<br/>cd B:\projects\Fire Behaviour Outputs\Hourly Output\%today%\HFI\<br/>B:<br/><br/>rem want to copy 4 Folders with 168 jpeg files each<br/><br/>rem C:\Firemod\temp<br/><br/>rem to<br/><br/>rem "B:\projects\Fire Behaviour Outputs\Hourly Output\%today%"<br/><br/>rem where this folder has created using the following codes<br/><br/><br/>echo D = Now : WScript.Echo Right(Year(D),4) _ &gt;%temp%\today.vbs<br/>echo ^&amp; Right(100+Month(D),2) ^&amp; Right(100+Day(D),2) &gt;&gt;%temp%\today.vbs<br/>type %temp%\today.vbs<br/>pause<br/><br/>for /f "tokens=1" %%a in (<br/>'cscript.exe //Nologo %temp%\today.vbs') do set today=%%a<br/><br/><br/>rem del %temp%\today.vbs<br/><br/>echo Hi<br/><br/>echo Firemode user, Todays date is : %today%<br/>pause<br/>cd "B:\projects\Fire Behaviour Outputs\Hourly Output\"<br/>md %today%<br/>md %today%\FBHI<br/>md %today%\HFI<br/>md %today%\min5ha<br/>md %today%\VI<br/><br/>cd %today%\FBHI<br/>dir<br/>copy C:\Firemod\temp\FBHI\*.jpg "B:\projects\Fire Behaviour Outputs\Hourly Output\%today%\FBHI\"<br/><br/>echo FBHI copied to B:\Fire Behaviour Outputs ...<br/><br/>cd %today%\HFI<br/>dir<br/>copy C:\Firemod\temp\HFI\*.jpg "B:\projects\Fire Behaviour Outputs\Hourly Output\%today%\HFI\"<br/><br/>echo HFI copied to B:\Fire Behaviour Outputs ...<br/><br/>cd %today%\MinutesTo5Ha<br/>dir<br/>copy C:\Firemod\temp\MinutesTo5Ha\*.jpg "B:\projects\Fire Behaviour Outputs\Hourly Output\%today%\min5ha\"<br/><br/>echo min5ha copied to B:\Fire Behaviour Outputs ...<br/><br/>cd %today%\VI<br/>dir<br/>copy C:\Firemod\temp\VI\*.jpg "B:\projects\Fire Behaviour Outputs\Hourly Output\%today%\VI\"<br/><br/>echo VI copied to B:\Fire Behaviour Outputs ...<br/><br/><br/>rem echo Created a folder for you; it is "B:\projects\Fire Behaviour Outputs\Hourly Output\"<br/><br/>rem each day file name will change and I need to copy those files regular basis.<br/><br/>Cd\<br/>C:<br/><br/><br/>copy2R<br/>======<br/><br/><br/>@echo off<br/>CD\<br/>cd "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing"<br/>R:<br/><br/>rem want to copy 3 Folders with 168 jpeg files each<br/><br/>rem C:\Firemod\temp<br/><br/>rem to<br/><br/>rem "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\%today%"<br/><br/>rem where this folder has created using the following codes<br/><br/><br/>echo D = Now : WScript.Echo Right(Year(D),4) _ &gt;%temp%\today.vbs<br/>echo ^&amp; Right(100+Month(D),2) ^&amp; Right(100+Day(D),2) &gt;&gt;%temp%\today.vbs<br/>type %temp%\today.vbs<br/>pause<br/><br/>for /f "tokens=1" %%a in (<br/>'cscript.exe //Nologo %temp%\today.vbs') do set today=%%a<br/><br/><br/>rem del %temp%\today.vbs<br/><br/>echo Hi<br/><br/>echo Firemode user, Todays date is : %today%<br/>pause<br/>cd "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\"<br/>md %today%<br/>md %today%\FBHI<br/>md %today%\HFI<br/>md %today%\VI<br/><br/>cd %today%\FBHI<br/>dir<br/>copy C:\Firemod\temp\FBHI\*.jpg "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\%today%\FBHI\"<br/><br/>echo FBHI copied to R:\Fire Behaviour Briefing<br/><br/>cd %today%\HFI<br/>dir<br/>copy C:\Firemod\temp\HFI\*.jpg "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\%today%\HFI\"<br/><br/>echo HFI copied to R:\Fire Behaviour Briefing<br/><br/>cd %today%\VI<br/>dir<br/>copy C:\Firemod\temp\VI\*.jpg "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\%today%\VI\"<br/><br/>echo VI copied to R:\Fire Behaviour Briefing<br/><br/><br/>rem echo Created a folder for you; it is "R:\50-SCC\05-StatePlanningSection\FireBehaviour\Fire Behaviour 2010_2011\SCC\Products\Fire Behaviour Briefing\"<br/><br/>rem each day file name will change and I need to copy those files regular basis.<br/><br/>Cd\<br/>C:<br/><br/><br/>Done . Thanks every one.</p></body></html>
8812.

Solve : set time in batch + 10sec more!?

Answer» <html><body><p>hi <br/>i want to set my time in "AT" command with +10sec more, something like that;<br/><br/>example:<br/>system time=01:24<br/>my time in batch set to=01:34<br/><br/>example:<br/><br/>at [system time + <a href="https://interviewquestions.tuteehub.com/tag/10-236933" style="font-weight:bold;" target="_blank" title="Click to know more about 10">10</a> sec] /interactive notepad.exe<br/><br/>i hope you understanding my question <br/><br/>SORRY FOR MY BAD ENGLISH Changing your system time is easy, but adding 10 seconds? Trying to figure out why you need to add 10 seconds from current system time. Do you want files to have date/time stamp 10 seconds in the future to what the current system time really is? Are you looking for a 10 second delay in which sleep or a bunch of pings to 127.0.0.1 can be used?i don't want 10 second delay!<br/>i want set current time + adding 10 second more to my batch file, like:<br/><br/>default command:<br/>AT [\\computername] time [/INTERACTIVE] "command"<br/><br/>i want:<br/><br/>at [system_time+10sec_more] /interactive cmd.exeQuote from: behzad-007 on <a href="https://interviewquestions.tuteehub.com/tag/august-385421" style="font-weight:bold;" target="_blank" title="Click to know more about AUGUST">AUGUST</a> 08, 2011, 04:32:48 AM</p><blockquote>i want set current time + adding 10 second more to my batch file, like:<br/></blockquote><br/>Like Dave asked, why are you doing it that way, and not using a simple 10 second delay?<br/>Quote from: Salmon Trout on August <a href="https://interviewquestions.tuteehub.com/tag/09-256415" style="font-weight:bold;" target="_blank" title="Click to know more about 09">09</a>, 2011, 11:56:56 PM<blockquote>Like Dave asked, why are you doing it that way, and not using a simple 10 second delay?<br/><br/></blockquote>because in "AT" command you must set time, you can't use delay! But you want it to happen in 10 seconds time. So why use AT?<br/>Quote from: behzad-007 on August 08, 2011, 04:32:48 AM<blockquote>i don't want 10 second delay!<br/>i want set current time + adding 10 second more to my batch file, like:<br/><br/>default command:<br/>AT [\\computername] time [/INTERACTIVE] "command"<br/><br/>i want:<br/><br/>at [system_time+10sec_more] /interactive cmd.exe<br/></blockquote><br/>It doesn't make sense. Why do you need the scheduler and not use a time delay as suggested? Does the AT command even support seconds? The system scheduler (GUI) does not.<br/><br/>Batch code does not really do date/time computes very well. All data is seen as a string, so even though you can do integer arithmetic, you run into that pesky problem of the seconds possibly carrying over to the next minute which in turn can carry over into the next hour and so forth. Pretty soon it's next year and then where are you?<br/><br/>VBScript can handle the date/time arithmetic and there is a <a href="https://interviewquestions.tuteehub.com/tag/class-18125" style="font-weight:bold;" target="_blank" title="Click to know more about CLASS">CLASS</a> for the AT scheduler.<br/><br/><br/><br/>You could always count one Mississippi, two Mississippi etc. When you get to ten Mississippi launch the missiles command. If you use military cadence, you can improve the ten second precision.Quote from: behzad-007<blockquote>hi<br/>example:<br/>system time=01:24<br/>my time in batch set to=01:34<br/></blockquote><br/>Judging by this, I am not convinced he knows the difference between seconds and minutes.<br/>Hi Sidewinder,<br/><br/>I agree with you. Both AT and <a href="https://interviewquestions.tuteehub.com/tag/schtasks" style="font-weight:bold;" target="_blank" title="Click to know more about SCHTASKS">SCHTASKS</a> don't support seconds at all.<br/><br/>Yes, it's difficult to calculate data/time in batch code, especially we need consider the next hour/month/year and leap-year. But we can use Epoch. You may want to have a look at the fuctions of Ritchie Lawrence.<br/><br/><a href="http://www.commandline.co.uk/lib/treeview/index.php">http://www.commandline.co.uk/lib/treeview/index.php</a></body></html>
8813.

Solve : Batch to move files by date?

Answer» <html><body><p>Hi. I need some help as I don't understand how this could be done. <br/><br/>I want to create a batch file that I would move into my startup directory and would execute each time I log on. I am using windows 7.<br/><br/>I have a video collection that is ever expanding and I want to organize the collection by date create a backup on a seperate drive. Basically it is set up like this:<br/><br/>1. A video gets downloaded and placed into <a href="https://interviewquestions.tuteehub.com/tag/f-236701" style="font-weight:bold;" target="_blank" title="Click to know more about F">F</a>:\Videos<br/>2. I need it to remain in this folder for 3 months after it was downloaded or I guess I would say <a href="https://interviewquestions.tuteehub.com/tag/modified-562543" style="font-weight:bold;" target="_blank" title="Click to know more about MODIFIED">MODIFIED</a>.<br/>3. After 3 Months from the last time it was modified to the current date set the computer it would place the video in the folder F:\Videos\3+Months <br/>4. After it finishes that loop and moves the applicable videos over I want it to check F:\Videos\3Months for any videos older than a year from the current date. <br/>5. If it finds videos over a year since they where last modified it would move them to F:\Videos\1+Years<br/><br/>6. Then, with possibly a seperate batch file, I need it to copy and make the same changes to a backup drive, I:\, with the same folder structures. However not just the videos but the whole F:\ drive with all its other files included. The problem I have with this is that if a video or any other file gets moved into another directory in F:\ it will cause two of the same files on I:\. How would it be possible to mirror the drive without copying all the data over again each time?Only method I can think of is very inefficient and large in routine size. Basically <a href="https://interviewquestions.tuteehub.com/tag/everytime-2623177" style="font-weight:bold;" target="_blank" title="Click to know more about EVERYTIME">EVERYTIME</a> the startup batch is triggered it passes a current days contents into the next day, making the current day folder clean, BUT you would have to have it execute in a manner from oldest to newest to shuffle everything down without passing yesterdays content into 2 days ago folder and merging content. <br/><br/>You would have 30 folders for your files downloaded within the last 30 days, then 90 folders for the last 90 days, and then a greater than 90 days folder that would be the final pool of all old files. The data from folder_30 would be passed into the Folder_31 which can be a sub-folder under 90_Days and continue on its shuffle every day until it makes its way to a final dump location in which you can seal the contents into folders with dated folder names to avoid overwriting of same filenames.<br/><br/>Biggest problem would be that it would <a href="https://interviewquestions.tuteehub.com/tag/take-662846" style="font-weight:bold;" target="_blank" title="Click to know more about TAKE">TAKE</a> a long time to execute the more files you have and the larger the size. I have used a similar system for a 7-day rolling backup where on the 8th day, the information overwrites the 1st days folder contents. Never made anything this large dealing with many large files to know how slow it will run.<br/><br/>To keep newer worked on projects seperate from older projects to solve the need for keeping newer altered or modified projects towards the front of this large shuffle, you simply copy say Folder_2's content to Folder_1 and so you have the original old file in Folder_2 and now you have the revised copy in Folder_1. Now tomorrow or next time you logon and the startup triggers your batch it will shuffle all files 1 folder down the line in reverse order to avoid merging projects.<br/><br/>Moving this much content is going to give your hard drive quite a workout, so you will definately want to run daily backups to say an external drive in case you work it to its death shuffling great amounts of data daily. Hard Drives are pretty rugged, but they can wear out under <a href="https://interviewquestions.tuteehub.com/tag/extreme-981946" style="font-weight:bold;" target="_blank" title="Click to know more about EXTREME">EXTREME</a> conditions!<br/><br/></p></body></html>
8814.

Solve : WINRAR command line?

Answer» <html><body><p>How can i delete *.rar after i extracted files from it in cmd?"<a href="https://interviewquestions.tuteehub.com/tag/c-3540" style="font-weight:bold;" target="_blank" title="Click to know more about C">C</a>:\Program Files\WinRAR\rar.exe" e D:\test\1.rar D:\test\archive\'<br/><br/>need switch or attribute to delete 1.rar in this lineHave you looked in the WinRar help?<br/>There is no command line switch to delete the archive after extraction, but you can open the WinRAR extract dialog and in both <a href="https://interviewquestions.tuteehub.com/tag/general-238723" style="font-weight:bold;" target="_blank" title="Click to know more about GENERAL">GENERAL</a> and Advanced tabs, set any options you wish and click "save options". After that if you <a href="https://interviewquestions.tuteehub.com/tag/use-241643" style="font-weight:bold;" target="_blank" title="Click to know more about USE">USE</a> WinRAR from the command line it will obey these <a href="https://interviewquestions.tuteehub.com/tag/option-25810" style="font-weight:bold;" target="_blank" title="Click to know more about OPTION">OPTION</a> settings.<br/><br/><br/><br/>Quote from: <a href="https://interviewquestions.tuteehub.com/tag/cimi-3579542" style="font-weight:bold;" target="_blank" title="Click to know more about CIMI">CIMI</a> on May 03, 2011, 09:09:04 AM</p><blockquote>How can i delete *.rar after i extracted files from it in cmd?<br/></blockquote>thats how</body></html>
8815.

Solve : Rename files?

Answer» <html><body><p>An application is creating ASCII files.<br/>Each file begins with 2011 <a href="https://interviewquestions.tuteehub.com/tag/en-446027" style="font-weight:bold;" target="_blank" title="Click to know more about EN">EN</a> the following 4 <a href="https://interviewquestions.tuteehub.com/tag/caracters" style="font-weight:bold;" target="_blank" title="Click to know more about CARACTERS">CARACTERS</a> are variable.<br/>I'm <a href="https://interviewquestions.tuteehub.com/tag/looking-1079184" style="font-weight:bold;" target="_blank" title="Click to know more about LOOKING">LOOKING</a> for a DOS-command which can <a href="https://interviewquestions.tuteehub.com/tag/rename-613846" style="font-weight:bold;" target="_blank" title="Click to know more about RENAME">RENAME</a> this file 2011**** into mytext_8_2011****.<br/>I tried the copy and rename command, but it doesn't work.<br/><br/>For <a href="https://interviewquestions.tuteehub.com/tag/example-239971" style="font-weight:bold;" target="_blank" title="Click to know more about EXAMPLE">EXAMPLE</a> : 20110807 --&gt; mytext_8_20110807<br/><br/>If I do<br/><br/>Rename 2011*.* mytext_8_2011*.*<br/><br/>the result is : mytext_8_2011 and not mytext_8_20110807<br/><br/>The same result for COPY 2011*.* mytext_8_2011*.*<br/><br/><br/>for /f "delims=" %%A in ('dir /b /a-d 2011*.*') do ren "%%A" "mytext_8_%%A"<br/><br/>Thank you !Code: <a>[Select]</a>@echo off<br/>for %%a in (2011*.*) do (<br/> ren "%%a" "mytext_8_%%a"<br/>)</p></body></html>
8816.

Solve : Winrar help?

Answer» <html><body><p>Hi,<br/><br/>I am Using Windows Xp, i trying to <a href="https://interviewquestions.tuteehub.com/tag/create-427332" style="font-weight:bold;" target="_blank" title="Click to know more about CREATE">CREATE</a> a new batch file which will do, compress a text file and delete after archive.<br/>my existing batch file content is below <br/><br/>set path="C:\Program Files (x86)\WinRAR\";%path%<br/>rar a -df -ep -mt2 C:\Test20110503.rar C:\Griddatafortheperiod20110503.txt<br/>pause<br/><br/>I need archive file name as like the source file name(Griddatafortheperiod20110503.txt)<br/>Current Archive file name is Test20110503.rar. please tell me how to create a archive file name as like source file name?<br/><br/>Thank you <br/><br/>ShanQuote</p><blockquote>I need archive file name as like the source file name(Griddatafortheperiod20110503.txt)</blockquote><br/>This should <a href="https://interviewquestions.tuteehub.com/tag/let-11597" style="font-weight:bold;" target="_blank" title="Click to know more about LET">LET</a> you specify the name for both. Is this what you need?<br/><br/>Code: <a>[Select]</a>set path="C:\Program Files (x86)\WinRAR\";%path%<br/>set /p textfile=Type the name of the file:<br/>rar a -df -ep -mt2 C:\%textfile%.rar C:\%textfile%.txt<br/>pause<br/>I <a href="https://interviewquestions.tuteehub.com/tag/read-619994" style="font-weight:bold;" target="_blank" title="Click to know more about READ">READ</a> your question again, and I think I might have <a href="https://interviewquestions.tuteehub.com/tag/misinterpreted-7696393" style="font-weight:bold;" target="_blank" title="Click to know more about MISINTERPRETED">MISINTERPRETED</a> your question. Do you want the batch to scan the folder for all text files and compress each one into a .rar file?Hi Linux711,<br/><br/> Thanks for your immediate reply... i <a href="https://interviewquestions.tuteehub.com/tag/tried-7272297" style="font-weight:bold;" target="_blank" title="Click to know more about TRIED">TRIED</a> your code its working fine for me and i got the result as i needed. thanks...<br/><br/>Shan</body></html>
8817.

Solve : Help with bat file?

Answer» <html><body><p>This is my <a href="https://interviewquestions.tuteehub.com/tag/first-461760" style="font-weight:bold;" target="_blank" title="Click to know more about FIRST">FIRST</a> attempt to make a bat file. I'm using Windows XP and I've tried using cmd to get to the files but it keeps stopping at C:\Documents and Settings\MrPiggss\Desktop instead of going into the My Documents folder.<br/><br/>Basically I need to be able to delete all files within:<br/><br/>C:\Documents and Settings\MrPiggss\My documents\Battlefield Play4Free\WebCache<br/><br/>and all file and folders with:<br/><br/>C:\Documents and Settings\MrPiggss\My Documents\Battlefield Play4Free\mods\main<br/><br/>Can someone help me out with this?Why not use windows to delete the directory through my computer and or windows exployer (windows key + E)<br/><br/>Then select the directories you wish to delete and press the delete key?Quote from: MrPiggss on August 13, 2011, 02:29:52 PM</p><blockquote>This is my first attempt to make a bat file. I'm using Windows XP and I've tried using cmd to get to the files but it keeps stopping at C:\Documents and Settings\MrPiggss\Desktop instead of going into the My Documents folder.<br/><br/>Basically I need to be able to delete all files within:<br/><br/>C:\Documents and Settings\MrPiggss\My documents\Battlefield Play4Free\WebCache<br/><br/>and all file and folders with:<br/><br/>C:\Documents and Settings\MrPiggss\My Documents\Battlefield Play4Free\mods\main<br/><br/>Can someone help me out with this?<br/></blockquote>cd WebCache<br/><br/>del /F *.*<br/>cd ..<br/>rd WebCache<br/><br/>@Rustys the reason I'd like a bat is because I have to clear these 2 folders every time to play a game. If I don't the game crashes. Rather than manually going through my computer yada yada yada... if I had a bat I <a href="https://interviewquestions.tuteehub.com/tag/could-410026" style="font-weight:bold;" target="_blank" title="Click to know more about COULD">COULD</a> just double click it would be easier.<br/><br/>@DanCollins<br/>do I need to specify the full location i.e. C:\Documents and Settings\MrPiggss\My documents\Battlefield Play4Free\WebCache or just do it as you have shown?Quote from: MrPiggss on August 13, 2011, 10:21:30 PM<blockquote>DanCollins<br/>do I need to specify the full location i.e. C:\Documents and Settings\MrPiggss\My documents\Battlefield Play4Free\WebCache or just do it as you have shown?<br/></blockquote><br/>Code: <a>[Select]</a>@echo off<br/>cd "C:\Documents and Settings\MrPiggss\My documents\Battlefield Play4Free\WebCache" <br/><br/>del /F *.*<br/>cd ..<br/>rd WebCache<br/><br/>cd "c:\Documents and Settings\MrPiggss\My Documents\Battlefield Play4Free\mods\main\"<br/><br/>del /F *.*<br/>cd ..<br/>rd main<br/>The above code must be saved to a batch file, deleterm.bat. The batch file can then be executed from the <a href="https://interviewquestions.tuteehub.com/tag/command-11508" style="font-weight:bold;" target="_blank" title="Click to know more about COMMAND">COMMAND</a> line.<br/>(Or point to the batch file and double click.)<br/><br/>C:\test&gt;deleterm.bat<br/><br/>p.s. Be careful when using *.* with delete. Make sure you have the correct files.<br/>You may <a href="https://interviewquestions.tuteehub.com/tag/name-237998" style="font-weight:bold;" target="_blank" title="Click to know more about NAME">NAME</a> the batch file any name you please: myfile.bat<br/>"path" "" is necessary when there is <a href="https://interviewquestions.tuteehub.com/tag/open-245076" style="font-weight:bold;" target="_blank" title="Click to know more about OPEN">OPEN</a> space inside the path.</body></html>
8818.

Solve : Check if file exists?

Answer» <html><body><p>Hi All,<br/>I need to create a daily log file that runs down a list of files and checks to be sure that todays files are there. Each day the name of the file changes with a new date stamp added. So far I found a script to create a log file by date and I was able to get the check of a file but I can't get the date in the file name to work.<br/><br/>Here is what I have.....<br/><br/><br/><br/>::::::::::::::::::::::::::::::::::::::::::::::::::::<br/>::Create a log file containing todays date<br/>::LogPath is the path to the folder where the log file will be saved<br/>::LogFileName is a descriptive name that will be added after the date<br/>::LogFileExt is the extension to be used <br/>::First get the date into a variable. Then convert the '/' to '-' so<br/>::the '/' won't be mistaken as a command line switch<br/>::if the file exists, a blank line and a separator line of equal <a href="https://interviewquestions.tuteehub.com/tag/signs-236644" style="font-weight:bold;" target="_blank" title="Click to know more about SIGNS">SIGNS</a><br/>::will be written at the <a href="https://interviewquestions.tuteehub.com/tag/end-239295" style="font-weight:bold;" target="_blank" title="Click to know more about END">END</a> of the file in <a href="https://interviewquestions.tuteehub.com/tag/case-240222" style="font-weight:bold;" target="_blank" title="Click to know more about CASE">CASE</a> the script runs more than<br/>::once a day.<br/>::::::::::::::::::::::::::::::::::::::::::::::::::::<br/>setlocal<br/>set LogPath=C:\Scripts\<br/>set LogFileExt=.log<br/>set LogFileName=Daily <a href="https://interviewquestions.tuteehub.com/tag/backup-18158" style="font-weight:bold;" target="_blank" title="Click to know more about BACKUP">BACKUP</a>%LogFileExt%<br/>::use set MyLogFile=%date:~4% instead to remove the day of the week<br/>set MyLogFile=%date%<br/>set MyLogFile=%MyLogFile:/=-%<br/>set MyLogFile=%LogPath%%MyLogFile%_%LogFileName%<br/>::Note that the quotes are REQUIRED around %MyLogFIle% in case it contains a space<br/>If NOT Exist "%MyLogFile%" goto:noseparator<br/>Echo.&gt;&gt;"%MyLogFile%"<br/>Echo.===================&gt;&gt;"%MyLogFile%"<br/>:noseparator<br/>echo.%Date% &gt;&gt;"%MyLogFile%"<br/>echo.%<a href="https://interviewquestions.tuteehub.com/tag/time-19467" style="font-weight:bold;" target="_blank" title="Click to know more about TIME">TIME</a>% &gt;&gt;"%MyLogFile%"<br/>:startbatch<br/>::<br/>@echo off<br/>rem check to see if a file exists<br/>if exist "\\peanuts\Applications\FTP\Archive\ABC.XYZEFT2011050420110504*" goto fileexists <br/><br/>goto nofile<br/><br/>:fileexists<br/>echo The file ABC.XYZEFT2011050420110504* exists ya all! &gt;&gt;"%MyLogFile%"<br/>rem other commands here .....<br/>goto end<br/><br/><br/><br/>:nofile<br/>echo the file %1 does not exist<br/>goto end<br/>:end<br/><br/>pause<br/>=========================================<br/><br/>Like I said if I type out the name of the file it writes a line in the log. What I have is about 10 files in 10 places all with date stamps in the name. I am trying to figure out how to run a batch file and then open the log each day to see if any are missing.<br/><br/>Thanks for any help<br/><br/><br/><br/>I figured it out......<br/><br/><br/>Thanks<br/></p></body></html>
8819.

Solve : dos/windows?

Answer» <html><body><p>please can <a href="https://interviewquestions.tuteehub.com/tag/someone-25657" style="font-weight:bold;" target="_blank" title="Click to know more about SOMEONE">SOMEONE</a> <a href="https://interviewquestions.tuteehub.com/tag/tell-1240910" style="font-weight:bold;" target="_blank" title="Click to know more about TELL">TELL</a> me the difference between dos and windowsYes, if by "someone" you mean "Google" - or my current favourite search <a href="https://interviewquestions.tuteehub.com/tag/engine-25861" style="font-weight:bold;" target="_blank" title="Click to know more about ENGINE">ENGINE</a>, Duck Duck Go: <a href="https://duckduckgo.com/?q=difference+between+DOS+Windows">http://duckduckgo.com/?q=difference+between+DOS+Windows</a>Pimp that novel!<br/><br/>The OP may be "one to watch"...<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/1-236780" style="font-weight:bold;" target="_blank" title="Click to know more about 1">1</a>. DOS<br/><br/><br/><br/>2. Windows<br/><br/>Quote from: Salmon Trout on August <a href="https://interviewquestions.tuteehub.com/tag/13-240254" style="font-weight:bold;" target="_blank" title="Click to know more about 13">13</a>, 2011, 04:00:55 AM</p><blockquote>Pimp that novel!<br/></blockquote><br/>Just about to.</body></html>
8820.

Solve : Batch file help?

Answer» <html><body><p>Depending on which of two physical external hard drives I connect to the same USB port on my computer that drive shows up on My Computer as either Drive F: or Drive H:.<br/><br/>I have composed a <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> file that copies certain <a href="https://interviewquestions.tuteehub.com/tag/files-20889" style="font-weight:bold;" target="_blank" title="Click to know more about FILES">FILES</a> to the "F: drive". However if the "H: drive" happens to be <a href="https://interviewquestions.tuteehub.com/tag/connected-929389" style="font-weight:bold;" target="_blank" title="Click to know more about CONNECTED">CONNECTED</a> at the <a href="https://interviewquestions.tuteehub.com/tag/time-19467" style="font-weight:bold;" target="_blank" title="Click to know more about TIME">TIME</a>, the copy process fails because the batch file is looking for the F: drive. But... I don't really care which physical drive (F: or H:) is being copied to.<br/><br/>I need to modify the batch file to go ahead and copy to the H drive if that one happens to be installed instead of the F drive. In pseudo code that might look like:<br/><br/>Is the drive connected to the USB port the F: drive ?<br/>Go ahead and copy the specified files<br/>Is the drive connected to the USB port the H: drive ?<br/>Go ahead and copy the specified files<br/><br/><br/>In other words, copy the specified files to the drive connected to the USB port no matter what drive letter the OS sees.<br/><br/>Using XP home with SP3<br/><br/><br/>Thanks for your assistance.I always thought removable drive letters were assigned sequentially, so I'm not understanding why you get two different assignments. Be that as it may, you can check which drive is mounted and proceed from there:<br/><br/>Code: <a>[Select]</a>@echo off<br/>setlocal<br/><br/>for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| findstr /c:" F " /c:" H "') do (<br/> xcopy &lt;put xcopy parameters here&gt; &amp;&amp; goto :eof<br/>)<br/><br/>Replace <em>&lt;put xcopy parameters here&gt;</em> with actual arguments. The drive letter is in the %%i variable. Leave the <em>&amp;&amp; goto :eof</em> as written.<br/><br/>Example: xcopy c:\windows\inf %%i:\backup /s /e &amp;&amp; goto :eof<br/><br/>Good luck. <br/><br/>PS. This snippet is specific to your request. VBScript or Powershell might be a better choice to create a generic script.</p></body></html>
8821.

Solve : Add single comma in place of any number of spaces?

Answer» <html><body><p>Looking for a way to add a (<a href="https://interviewquestions.tuteehub.com/tag/single-644669" style="font-weight:bold;" target="_blank" title="Click to know more about SINGLE">SINGLE</a> comma) in between data like below to force non comma delimited data to become comma delimited...any suggestions on how I can do this for a text document with the raw data like below in a batch ( or vb script ) so that I dont have to run this manual notepad replace 3 step process for daily data?<br/><br/>Deathstarr Rank 4 80 0 0 <br/>Dianniah Rank 4 80 0 0 <br/>Minnieknight Rank 4 80 0 0 <br/>Mortimur Rank 4 80 0 0 <br/>Shamadar Rank 4 80 0 0 <br/>Starrgantis Rank 4 80 0 0 <br/>Starrgazer Rank 4 80 0 0 <br/><br/>Trying to get away from this Manual NOTEPAD " Find All Replace " Process:<br/>(1.) Replacing ALL the (spaces) with ( , ) <br/>--- &gt; and then in two locations I get (,,,,,,) and (,,)<br/>(2.) I then need to replace ( ,,,,,, ) with ( , )<br/>(3.) Then finally replace ( ,, ) with ( , ) <br/>---&gt; So that all data is single comma delimited.<br/><br/>In the end I want clean comma delimited like below:<br/><br/>Deathstarr,Rank,4,80,0, <br/>Dianniah,Rank,4,80,0,0,<br/>Minnieknight,Rank,4,80,0,0,<br/>Mortimur,Rank,4,80,0,0,<br/>Shamadar,Rank,4,80,0,0,<br/>Starrgantis,Rank,4,80,0,0, <br/>Starrgazer,Rank,4,80,0,0,<br/><br/>Any suggestions or solutions to automate this space replacement and make it a nice comma delimited file?<br/><br/>If you use space(s) as the token delimiter, you can write out each line as a set of tokens with commas in between. One or more spaces will be replaced by 1 comma. I am curious why you want a trailing comma? I have included one after %%<a href="https://interviewquestions.tuteehub.com/tag/f-236701" style="font-weight:bold;" target="_blank" title="Click to know more about F">F</a> as you can see, but I wonder why you need it.<br/><br/>e.g (assuming 6 tokens on each line)<br/><br/><br/>Code: <a>[Select]</a><br/>if exist output.csv del output.csv<br/>for /f "tokens=1-6 delims= " %%A in ('type input.txt') do (<br/> echo %%A,%%B,%%C,%%D,%%E,%%F,&gt;&gt;output.csv<br/> )<br/><br/>I started this before Dias's post, and yet notice my keen observation in the comments.... sort of, I was right about "being able to do it better" anyway... (that is, "other peeps")<br/><br/><br/>Also, it removes all trailing spaces... don't think that was what you wanted... <br/><br/>Code: <a>[Select]</a><br/>Dim InName,OutName<br/>Dim FSO<br/>set FSO = CreateObject("Scripting.FileSystemObject")<br/>if wscript.arguments.count &lt; 2 then<br/> wscript.echo "Spc2Comma &lt;InputFile&gt; &lt;OutputFile&gt;"<br/>end if <br/>InName = wscript.arguments(0)<br/>Outname = wscript.arguments(1)<br/><br/>Dim InFile,OutStream<br/>Dim InStream<br/>Dim ReadStr<br/>'Set InFile = FSO.GetFile(InName)<br/><br/>set InStream=FSO.OpenTextFile(InName,1) <br/>Set OutStream=FSO.CreateTextFile(Outname,-1)<br/><br/>ReadStr = InStream.ReadAll()<br/>ReadStr = Replace(ReadStr," ", ",")<br/>Do Until Instr(readStr,",,") = 0<br/>'replace two comma's with one...<br/> ReadStr = Replace(readstr,",,",",")<br/><br/>Loop<br/>Do Until Instr(readstr," ") = 0<br/>'replace two spaces with one...<br/> readstr = replace(readstr, " "," ")<br/>loop<br/><br/><br/>'last replace a comma and crlf combination with just a crlf...<br/>readstr = replace(readstr,"," + Chr(13) + Chr(10) + ",",chr(13) + chr(10))<br/>'lastly, cut off last char if it is a comma.<br/>'this is a terrible kludge and I'm sure more vbscript able peeps could do this better...<br/>if right(readstr,1) = "," then <br/>wscript.echo "*censored*"<br/>readstr = mid(readstr,1,len(readstr)-3)<br/>end if <br/>outStream.Write ReadStr<br/><br/>outstream.close<br/>InStream.Close <br/><br/>Except that mine will do the grunt work in one line<br/><br/>Code: <a>[Select]</a>@echo off<br/>set /p infile=File to process ?<br/>set /p otfile=Output file name ?<br/>if exist "%otfile%" del "%otfile%"<br/>for /f "tokens=1-6 delims= " %%A in ( ' type "%infile%" ' ) do echo %%A,%%B,%%C,%%D,%%E,%%F,&gt;&gt;"%otfile%"<br/>Thanks Dias &amp; BC<br/><br/>And regarding the trailing comma .... this was caused by notepads replace of spaces and finding a single space in the datas formatting after the last piece of data on each line. It is not required, but also doesnt scue the output for my application.<br/><br/>Thanks for solving this for me so I can avoid the 3 step manual replace process, and I have saved a copy of this so that in the future I can look back and tweak it for other replacement uses.<br/><br/>Many thanks to both of you in your efforts! How can I do the same thing with my data set? First row is my column headings<br/><br/>I've been struggling with this for hours.... Any help would be greatly appreciated. Thanks in <a href="https://interviewquestions.tuteehub.com/tag/advance-850602" style="font-weight:bold;" target="_blank" title="Click to know more about ADVANCE">ADVANCE</a>.<br/><br/> samid upn fn ln display canchpwd pwdneverexpires disabled <br/> 134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> Mike Smith 927 Mike Smith 927 yes no no Quote from: ry8200 on August 04, 2011, 01:23:26 PM</p><blockquote>How can I do the same thing with my data set? First row is my column headings<br/><br/>I've been struggling with this for hours.... Any help would be greatly appreciated. Thanks in advance.<br/><br/> samid upn fn ln display canchpwd pwdneverexpires disabled <br/> 134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> Mike Smith 927 Mike Smith 927 yes no no <br/></blockquote><br/>comma <br/>« Sent to: ry8200 on: Today at 06:03:57 PM » | Reply | Quote | Delete | <br/><br/>Code: <a>[Select]</a>@echo off &amp; setLocal EnableDELAYedeXpansion<br/>del otfile.txt &gt; nul<br/>for /f "delims=" %%i in (infile.txt) do (<br/>call :sub %%i<br/>)<br/>echo.<br/>type otfile.txt<br/>goto :eof<br/><br/>:sub<br/><br/>echo %*<br/><br/>:loop<br/><br/><br/>echo/|set /p ="%1," &gt;&gt; otfile.txt<br/><br/>shift<br/><br/>if "%1"=="" (<br/>goto :end<br/>)<br/>goto :loop<br/>:end<br/>echo. &gt;&gt; otfile.txt<br/><br/><br/><br/><br/>Output:<br/><br/>c:\test&gt;comma2.bat<br/>134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> MikeSmith 927 yes no<br/>134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> MikeSmith 927 yes no<br/>134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> MikeSmith 927 yes no<br/>134-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> JoeLong 927 yes no no yes<br/><br/>134-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,MikeSmith,927,yes,no,<br/>134-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,MikeSmith,927,yes,no,<br/>134-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,MikeSmith,927,yes,no,<br/>134-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,JoeLong,927,yes,no,no,yes,<br/><br/>c:\test&gt;<br/><br/>ref:<br/><br/><a href="https://stackoverflow.com/questions/4479734/echo-with-no-new-line-cr-lf">http://stackoverflow.com/questions/4479734/echo-with-no-new-line-cr-lf</a><br/><br/>That kind of work can be done by a spreadsheet program.1. This thread has been revived by ry8200 after a gap of over two and a half years. ry8200, if you are genuine, and not Bill's sock puppet, as certain internal evidence suggests, start your own thread. Better still, read this one, where the solution was clearly described by my friend Dias de Verano, in February 2009.<br/><br/>2. Fred35 is, as I suspected ever since he first appeared, Billrich.<br/><br/>Honestly Salmon Trout - Sock puppet??? Are you kidding me... If this is how a new person is treated in this forum, then I'll take my request somewhere else. I am a real person with an issue that falls in line with this post and the previous issue that DaveLembke had; so I thought it would make sense to revive this post.<br/><br/>Anyway, moving on.<br/><br/>The new issue I'm having is two of the fields of data, called "fn" and "display" have spaces in them (for example "Display" = "John Smith D1234567"), that I need to keep, but I want to replace all the other spaces with a comma.<br/><br/><strong>The data pulled from my DSQUERY is:</strong><br/> samid upn fn ln display canchpwd pwdneverexpires disabled <br/> 123-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> John Smith D1234567 John Smith D1234567 yes no no <br/> 456-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> Mike Smith U1234567 Mike Smith U1234567 yes no no <br/><br/><strong>The output would need to look like this:</strong><br/>samid,upn,f,ln,display,canchpwd,pwdneverexpires,disabled<br/>123-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,John Smith,D1234567,John Smith D1234567,yes,no,no <br/>456-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,Mike Smith,U1234567,Mike Smith U1234567,yes,no,no Did you read what was said about starting your own thread? You have revived a thread from 2009.<br/>Anyhow,<br/><br/>@echo off<br/>setlocal enabledelayedexpansion<br/>set InputFileName=Input.txt<br/>set OutputFileName=output.csv<br/>set line=1<br/>if exist "%OutputFileName%" del "%OutputFileName%"<br/>for /f "tokens=1-11 delims= " %%A in ('type "%InputFileName%"') do (<br/>if !line! equ 1 (<br/>set output=%%A,%%B,%%C,%%D,%%E,%%F,%%G,%%H<br/>) else (<br/>set output=%%A,%%B,%%C %%D,%%E,%%F %%G %%H,%%I,%%<a href="https://interviewquestions.tuteehub.com/tag/j-236599" style="font-weight:bold;" target="_blank" title="Click to know more about J">J</a>,%%K<br/>)<br/>echo !output! &gt;&gt; "%OutputFileName%"<br/>set /a line+=1<br/>)<br/>echo Input:<br/>echo.<br/>type "%InputFileName%"<br/>echo.<br/>echo Output:<br/>echo.<br/>type "%OutputFileName%"<br/><br/><br/>Input:<br/><br/>samid upn fn ln display canchpwd pwdneverexpires disabled<br/>123-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> John Smith D1234567 John Smith D1234567 yes no no<br/>456-2 <a href="/cdn-cgi/l/email-protection">[emailprotected]</a> Mike Smith U1234567 Mike Smith U1234567 yes no no<br/><br/>Output:<br/><br/>samid,upn,fn,ln,display,canchpwd,pwdneverexpires,disabled<br/>123-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,John Smith,D1234567,John Smith D1234567,yes,no,no<br/>456-2,<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>,Mike Smith,U1234567,Mike Smith U1234567,yes,no,no<br/><br/></body></html>
8822.

Solve : show batch output in msg box!?

Answer» <html><body><p>hi<br/>i want to show my final output in massage box, i don't know but something like that, <br/><br/>code:<br/><br/>@echo off<br/>set/<a href="https://interviewquestions.tuteehub.com/tag/p-236832" style="font-weight:bold;" target="_blank" title="Click to know more about P">P</a> drive="your drive&gt;"<br/>fsutil volume diskfree %drive%<br/><br/>output in massage box, like,<br/>msg * "OUTPUT_OF_fsutil volume diskfree %drive%"<br/><br/>tnxbatch scripting does not have message boxes. VBScript does.<br/>you can simply make your own exe with this functionality using another language. I have a program I could upload that does exactly what you want, but you will have to wait for me to get it from my home computer in a few days bc I am on vacation. If it is mandatory, I can give you some vb or c++ code.With VBScript, you could run the <strong><strong>fsutil</strong></strong> command, capture the output into a variable and then display a message box. With NT batch, you'd have to capture the output in a file, then push it into the message box:<br/><br/>This won't win any beauty contests, but it might take home the prize for Miss Congeniality:<br/><br/>Code: <a>[Select]</a>@echo off<br/>setlocal<br/><br/>set /p drive=Enter Drive Letter: <br/><br/>for /f "tokens=* delims=" %%i in ('fsutil volume diskfree %drive%:') do (<br/> echo %%i &gt;&gt; text<br/>) <br/><br/>&lt;text msg %username%<br/>del text<br/><br/>At the prompt enter only the drive letter; the batch file will insert the colon.<br/><br/>Good luck. Nicely spotted, Sidewinder, I had forgotten about msg. I played around with it a bit<br/><br/>Code: <a>[Select]</a>@echo off<br/>set /p drive="Enter Drive Letter: "<br/>Echo Statistics for Drive %drive%: &gt; text<br/>for /f "tokens=* delims=" %%i in ('fsutil volume diskfree %drive%:') do echo %%i &gt;&gt; text<br/>&lt;text msg %username%<br/>del text<br/>it is so much cleaner to just write a program in c, copy it to system32, and then call it from batch by just typing <a href="https://interviewquestions.tuteehub.com/tag/msgbox-566001" style="font-weight:bold;" target="_blank" title="Click to know more about MSGBOX">MSGBOX</a> [bla bla]Quote from: Linux711 on August 06, 2011, 08:08:00 PM</p><blockquote>it is so much cleaner to just write a program in c, copy it to system32, and then call it from batch by just typing msgbox [bla bla]<br/></blockquote><br/>You can do this already from VBscript<br/>Quote from: Salmon Trout on August 07, 2011, 01:07:01 AM<blockquote>You can do this already from VBscript<br/></blockquote><br/>... and you can do a lot more things...<br/><br/>As I shall <a href="https://interviewquestions.tuteehub.com/tag/proceed-592932" style="font-weight:bold;" target="_blank" title="Click to know more about PROCEED">PROCEED</a> to demonstrate...<br/><br/>Code: <a>[Select]</a>' Make Shell object available<br/>Set Shell = CreateObject("Wscript.Shell")<br/><br/>' Force use of cscript.exe so we can use console input<br/>If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then<br/> Shell.Run "cscript """ &amp; WScript.ScriptFullName &amp; """", 1, False<br/> WScript.Quit<br/>End If<br/><br/>' Get console input from user<br/>' 1. Write prompt to console, no newline<br/>wscript.stdout.Write "Enter drive letter: "<br/><br/>' 2. Get user input terminated by Enter<br/>UserInput = Wscript.StdIn.ReadLine<br/><br/>' 3. Just get first character in case they type C: or similar<br/>DriveLetter = Mid(UserInput,1,1)<br/><br/>' Start building string to pass to messagebox<br/>' Force drive letter to upper case (just because we can!)<br/>MessageString = "Drive letter is: " &amp; UCase(DriveLetter)<br/><br/>' This is the string we pass to Shell for execution<br/>FsUtilString = "fsutil volume diskfree " &amp; DriveLetter &amp; ":"<br/><br/>' Start FSUtil running<br/>Set oExec = Shell.Exec(FsUtilString)<br/><br/>' While it has not yet finished...<br/>Do While oExec.StdOut.AtEndOfStream &lt;&gt; True<br/><br/> ' Get each line in turn from fsutil<br/> FsUtilOutputLine = oExec.StdOut.ReadLine<br/> <br/> ' Split the line at the colon<br/> SplitLineArray = Split(FsUtilOutputLine,":")<br/> <br/> ' We have split Array has 2 elements, 0 and 1<br/> ' Because there is 1 colon in each line<br/> LineText = SplitLineArray(0)<br/> ByteText = SplitLineArray(1)<br/> <br/> ' Force the bytes value string into a number<br/> ByteNumb = Eval(ByteText)<br/> <br/> ' Some <a href="https://interviewquestions.tuteehub.com/tag/handy-479297" style="font-weight:bold;" target="_blank" title="Click to know more about HANDY">HANDY</a> values demonstrated<br/> KiloBytes = ByteNumb / 1024<br/> MegaBytes = ByteNumb / (1024 * 1024)<br/> GigaBytes = ByteNumb / (1024 * 1024 * 1024)<br/> <br/> ' We'll show GB in brackets after the bytes figure<br/> ' We'll reduce the large number of decimal places to just 2<br/> GBFormat = FormatNumber(Gigabytes,2)<br/> <br/> ' Build up the string for the message box<br/> ' Insert a carriage return / line feed after each line (except the last)<br/> ' So that they will appear as separate lines in the box<br/> MessageString=MessageString &amp; VBcrlf &amp; LineText &amp; ":" &amp; ByteText &amp; " (" &amp; GBFormat &amp; " GB)"<br/><br/>Loop<br/><br/>' Retval is a dummy value in this case since we are only using 1 Button (OK button)<br/>' Therefore we are not concerned about the return value<br/>Retval = MsgBox(MessageString, vbOKOnly, "Disk Free and Used Space")<br/><br/><br/><br/><br/><br/>thanks for reply<br/><br/>this code is work, but i don't know vbScript language Quote from: behzad-007 on August 07, 2011, 07:13:05 AM<blockquote>thanks for reply<br/><br/>this code is work, but i don't know vbScript language <br/></blockquote><br/>Now is the time to start learning! I put lots of comments in there. Or you have batch code above.<br/><br/><br/><br/>You can do it in 5 lines of batch<br/><br/>Code: <a>[Select]</a>@echo off<br/>Set /p drive=Enter Drive Letter:<br/>fsutil volume diskfree %drive%: &gt; text.txt<br/>&lt;text.txt msg %username%<br/>del text.txt<br/>In fact you can do it in 1 line<br/><br/>Code: <a>[Select]</a>@Set /p drive=Enter Drive Letter: &amp; echo Drive %drive%: &gt; text.txt &amp; fsutil volume diskfree %drive%: &gt;&gt; text.txt &amp; &lt;text.txt msg %username% &amp; del text.txttnx so much<br/><br/>5 line batch worked! <br/>but 1 line code is not <a href="https://interviewquestions.tuteehub.com/tag/working-243555" style="font-weight:bold;" target="_blank" title="Click to know more about WORKING">WORKING</a> in my pc!! Quote from: behzad-007 on August 08, 2011, 03:17:48 AM<blockquote>but 1 line code is not working in my pc!! <br/></blockquote>Yes it has an error I will try to fix it<br/></body></html>
8823.

Solve : Buffer = ? In MS DOS config.sys what is the maximum?

Answer» <html><body><p>I had a <a href="https://interviewquestions.tuteehub.com/tag/pc-590329" style="font-weight:bold;" target="_blank" title="Click to know more about PC">PC</a> die on me that was running a Operating System used in CNC programming. I changed the PC and had Win 98 installed which is what was on the other. When trying to transfer files within this DOS <a href="https://interviewquestions.tuteehub.com/tag/driven-344371" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVEN">DRIVEN</a> software I get a Buffer size exceeded error. In Config.sys, what is the maximum number I could put in this field? Or is it hard coded. Also, is this just a string buffer? <br/><br/><a href="https://interviewquestions.tuteehub.com/tag/thanks-665909" style="font-weight:bold;" target="_blank" title="Click to know more about THANKS">THANKS</a> <br/>Richwhat number do you currently have in your BUFFERS= line? BUFFERS=75 is a common setting. This setting is for file i/o not strings.<br/>Quote from: remullis on March 25, 2010, 07:14:38 PM</p><blockquote>I had a PC die on me that was running a Operating System used in CNC programming. I changed the PC and had Win 98 installed which is what was on the other. When trying to transfer files within this DOS driven software I get a Buffer size exceeded error. In Config.sys, what is the maximum number I could put in this field? Or is it hard coded. Also, is this just a string buffer? <br/><br/>Thanks <br/>Rich<br/></blockquote>0 to <a href="https://interviewquestions.tuteehub.com/tag/255-297944" style="font-weight:bold;" target="_blank" title="Click to know more about 255">255</a> the more you add,more memory is used,i have 768mb of memory on one of my computers and i have added 180 buffers and it is faster. Just edit the config.sys file example buffers=180 then save and exit you must restart your computer for this to take effect. and I am running xp pro sp2<br/>This thread is a year old (not that the answer would make any more sense if it wasn't).180 buffers ? ? ?Nothing in config.sys changes the way Windows XP works.<br/><br/>In fact, No version of NT even Looks at config.sys during startup. Any perceived speed increase is only perceived and not actual.Don't spoil his fun....he may spend weeks working on another non-functional speed tweak...Quote from: patio on May 05, 2011, 07:04:59 AM<blockquote>Don't spoil his fun....he may spend weeks working on another non-functional speed tweak...<br/></blockquote>Some all around speed "tips":<br/><br/>-If you wear unmatched socks it can increase file access times by over 50%! <br/><br/>-People with fillings should avoid using the mouse, and use keyboard operations where possible. Experiments done on guinea pigs have revealed that this can increase throughput by a factor of 5 compared to a guinea pig sitting on your keyboard.<br/><br/>-If you have a game controller plugged it, put flame stickers on it. It makes everything go faster.<br/><br/>-If you have more then <a href="https://interviewquestions.tuteehub.com/tag/512mb-324488" style="font-weight:bold;" target="_blank" title="Click to know more about 512MB">512MB</a> of memory, this can slow down newer operating systems like Windows Vista, because they deal with memory in something called Blubbors*. a Blubbor takes a long time to transfer, and the more blubbors you have, the longer everything takes. Windows Vista has a minimum requirement of at least 3.51 Blubbors, but has been known to run on machines as low as a half blubbor (also known as a scaligree**). Anyway, the more blubbors the slower t hings go, and the more memory you have, the more blubbors, so if you remove memory things will go faster. No arguing with logic.<br/><br/><br/><em>*Blubbors do not exist. If you think you are seeing a blubbor, it's a hallucination. Seek medical aid immediately.</em><br/><em>**scaligree's were discovered in 1636 by the Algonquin native tribe in North America. It smells like daffodils.</em>Blubbors do exist...</body></html>
8824.

Solve : Batch file to login to my mail id?

Answer» <html><body><p>Hi All,<br/><br/>I was wondering if it is possible to create a batch file which opens <a href="http://www.yahoomail.com">www.yahoomail.com</a>, enters my userid and password and logs into the email account.<br/><br/>Is this possible in DOS? Is it possible for <a href="https://interviewquestions.tuteehub.com/tag/us-243201" style="font-weight:bold;" target="_blank" title="Click to know more about US">US</a> to send <a href="https://interviewquestions.tuteehub.com/tag/inputs-245712" style="font-weight:bold;" target="_blank" title="Click to know more about INPUTS">INPUTS</a> to webpage through command line.<br/>Can anybody help in this?<br/>Salman trout, can u pls give ur useful inputs.<br/><br/>Thanks in advance..plz tell me about batch file<br/>Quote</p><blockquote>Is this possible in DOS? Is it possible for us to send inputs to webpage through command line.<br/></blockquote><br/>Not that I'm aware of. You might <a href="https://interviewquestions.tuteehub.com/tag/try-1428546" style="font-weight:bold;" target="_blank" title="Click to know more about TRY">TRY</a> VBScript which has several <a href="https://interviewquestions.tuteehub.com/tag/ways-25480" style="font-weight:bold;" target="_blank" title="Click to know more about WAYS">WAYS</a> of handling this. <br/><br/>One would be to fire up the browser and send keystrokes to the rendered page. This can be successful, but timing is everything and any misfire can produce unexpected results.<br/><br/>A second way would be to create an instance of the browser where you can script both the browser and the rendered page. <br/><br/>You can use this little snippet as a template which shows off the second method:<br/><br/>Code: <a>[Select]</a>Set IE = CreateObject("InternetExplorer.Application") <br/>Set WshShell = WScript.CreateObject("WScript.Shell") <br/><br/>IE.Navigate "http://www.yahoomail.com" <br/>IE.Visible = True <br/><br/>Do<br/> WScript.Sleep 5000<br/>Loop While IE.Busy<br/> <br/>IE.Document.All.Item("login").Value = "username" 'Change username as needed<br/>IE.Document.All.Item("passwd").Value = "password" 'Change password as needed<br/><br/>WshShell.SendKeys "{ENTER}"<br/><br/>Good luck. <br/><br/>@Balwinder Singh: <a href="https://interviewquestions.tuteehub.com/tag/start-239994" style="font-weight:bold;" target="_blank" title="Click to know more about START">START</a> your own thread and please be more specific. <br/><br/>This is probably nothing but I'm tired of chasing shadows around every corner.</body></html>
8825.

Solve : Abusing the old DOS DEBUG.COM program?

Answer» <html><body><p>Some <a href="https://interviewquestions.tuteehub.com/tag/older-1130466" style="font-weight:bold;" target="_blank" title="Click to know more about OLDER">OLDER</a> articles about DOS and batch programming <a href="https://interviewquestions.tuteehub.com/tag/mention-547565" style="font-weight:bold;" target="_blank" title="Click to know more about MENTION">MENTION</a> the program named DEBUG.COM to write short bits of code to change things. <br/>The now is <a href="https://interviewquestions.tuteehub.com/tag/considered-929972" style="font-weight:bold;" target="_blank" title="Click to know more about CONSIDERED">CONSIDERED</a> an abusive practice. So If you decide to use DEBUG to try an experiment, you may want to read this recent post on <a href="https://interviewquestions.tuteehub.com/tag/another-876628" style="font-weight:bold;" target="_blank" title="Click to know more about ANOTHER">ANOTHER</a> site.<br/><a href="http://www.robvanderwoude.com/debug.php"><strong>(Ab)using DEBUG</strong></a><br/>Please note the remarks about 32 bit and 64 bit Windows.<br/><em>Do you agree?</em>I'd see the Icon at the top right of the page you linked to...1. Who says it's an abusive practice?<br/>2. I <a href="https://interviewquestions.tuteehub.com/tag/already-1974237" style="font-weight:bold;" target="_blank" title="Click to know more about ALREADY">ALREADY</a> knew 64-bit Windows won't run 16-bit stuff.<br/>3. Why should we have any opinion at all about this?<br/><br/><br/></p></body></html>
8826.

Solve : Append file extensions to a number of files?

Answer» <html><body><p>Hey all!<br/><br/>I have a bunch of mp3 files with missing file extensions. What is the best way to append the "mp3" suffix to them?<br/><br/><strong>Example 1</strong><br/>Say you have following files...<br/><br/>Quote</p><blockquote>01 Audioslave - Revelations.mp3<br/>02 Blur - Bang.mp3<br/>03 Cake - Jolene.mp3<br/>04 Doves - Pounding.mp3<br/>05 Everlast - Ends.mp3</blockquote><br/>Now, if you for some reason want to change the suffix from "mp3" to something like, I don't know, maybe aac. You would type something like this in the Windows command line.<br/><br/>Code: <a>[Select]</a>ren *.mp3 *.aac<br/>You hit Enter and you're done.<br/><br/>They should now be listed as...<br/><br/>Quote<blockquote>01 Audioslave - Revelations.<strong>aac</strong><br/>02 Blur - Bang.<strong>aac</strong><br/>03 Cake - Jolene.<strong>aac</strong><br/>04 Doves - Pounding.<strong>aac</strong><br/>05 Everlast - Ends.<strong>aac</strong></blockquote><br/>It's easy when they all have something in common, like the "mp3" suffix in this case. But what if they don't have anything in the name that's common to all files? You won't be able to use any combination of wildcard characters to match the files you want. Am I right?<br/><br/><strong>Example 2</strong><br/>It's easy when they have something in common. Like this...<br/><br/>Quote<blockquote>01 Blur - Bang<br/>02 Blur - Repetition<br/>03 Blur - Fool<br/>04 Blur - Birthday<br/>05 Blur - Jets</blockquote><br/>In this case you have "blur" as the common denominator. So you could type something like this...<br/><br/>Code: <a>[Select]</a>ren *blur* *.mp3<br/>That should add the "mp3" suffix to all files containing the word "blur". So you get...<br/><br/>Quote<blockquote>01 Blur - Bang.<strong>mp3</strong><br/>02 Blur - Repetition.<strong>mp3</strong><br/>03 Blur - Fool.<strong>mp3</strong><br/>04 Blur - Birthday.<strong>mp3</strong><br/>05 Blur - Jets.<strong>mp3</strong></blockquote><br/>But what if you don't have a common denominator in all files, like in example 2?<br/><br/>I tried typing this...<br/><br/>Code: <a>[Select]</a>ren 01*;02*;03*;04*;05* *.mp3<br/>But the command line only returned syntax error.<br/><br/>So I tried replacing the semicolon with a plus sign, like this...<br/><br/>Code: <a>[Select]</a>ren 01*+02*+03*+04*+05* *.mp3<br/>Command line just says that the file could not be found.<br/><br/>Inserting spaces before and after the plus sign doesn't help either. It just gives syntax error. So there doesn't seem to be a way to cheat on this. While you may be able to select multiple files using the "file+file" format, you can't use the <a href="https://interviewquestions.tuteehub.com/tag/asterisk-886211" style="font-weight:bold;" target="_blank" title="Click to know more about ASTERISK">ASTERISK</a> character at the same time in that same command line.<br/><br/>So I tried...<br/><br/>Code: <a>[Select]</a>ren 01* *.mp3<br/>This works, but you have to repeat it for every file. So it would be like...<br/><br/>Code: <a>[Select]</a>ren 01* *.mp3<br/>ren 02* *.mp3<br/>ren 03* *.mp3<br/>ren 04* *.mp3<br/>ren 05* *.mp3<br/>So, now I'm thinking that one may need to create a batch file. But wait a second... a batch file?... just to perform this simple task? Is that really necessary? Is there no other way around?<br/><br/>You would still need to write the batch file. That consumes time, and while at it you may as well go ahead and add "mp3" to the files manually, one by one, in the Windows Explorer!<br/><br/>So...<br/><br/>Thoughts? Ideas? Let me know!Quote from: Fractalogic on August 07, 2011, 11:14:59 AM<blockquote>I have a bunch of mp3 files with missing file extensions. What is the best way to append the "mp3" suffix to them?<br/><br/>[...]<br/><br/>You would still need to write the batch file. That consumes time, and while at it you may as well go ahead and add "mp3" to the files manually, one by one, in the Windows Explorer!<br/></blockquote><br/>You appear to like typing, judging by the length of your post, so maybe you would prefer to rename them all manually using Explorer, but if you are prone to the type of accident that strips files of their extensions, then the time spent writing a batch file, or a command-line one-liner that you can save as a text file and paste to the prompt, will soon be saved. In any case, you will only need to copy and paste the code below, making any alterations needed to fit your particular needs. <br/><br/>Code: <a>[Select]</a>@for /f "delims=" %A in ( ' dir /s /b /a-d "C:\My MP3 Collection\Folder in Question" ' ) do ren "%~dpnxA" "%~nA.mp3"<br/>Note:<br/><br/>1. This is for the prompt. <br/>2. If you want to use it as a batch file change the single percent signs % to double ones %% so that %A becomes %%A and %~dpnxA becomes %%~dpnxA and %~nA becomes %%~nA.<br/>3. It operates on all files in the named folder and all files in any sub folders also. If you don't want subfolders to be affected, delete the /s switch from the DIR command in the brackets.<br/>4. It will add the .mp3 extension to all files that do not have an extension, and it will replace any other extension with .mp3.<br/><br/>Quote from: Salmon Trout on August 07, 2011, 12:01:33 PM<blockquote>You appear to like typing, judging by the length of your post, so maybe you would prefer to rename them all manually using Explorer, but if you are prone to the type of accident that strips files of their extensions, then the time spent writing a batch file, or a command-line one-liner that you can save as a text file and paste to the prompt, will soon be saved. In any case, you will only need to copy and paste the code below, making any alterations needed to fit your particular needs. <br/><br/>Code: <a>[Select]</a>@for /f "delims=" %A in ( ' dir /s /b /a-d "C:\My MP3 Collection\Folder in Question" ' ) do ren "%~dpnxA" "%~nA.mp3"<br/>Note:<br/><br/>1. This is for the prompt. <br/>2. If you want to use it as a batch file change the single percent signs % to double ones %% so that %A becomes %%A and %~dpnxA becomes %%~dpnxA and %~nA becomes %%~nA.<br/>3. It operates on all files in the named folder and all files in any sub folders also. If you don't want subfolders to be affected, delete the /s switch from the DIR command in the brackets.<br/>4. It will add the .mp3 extension to all files that do not have an extension, and it will replace any other extension with .mp3.<br/></blockquote><br/>I sure do! That's why I'm still stuck in DOS! Duh! <br/><br/>I would say that my primary objective is to learn how to do things like these. I am very eager to learn as much as possible about computers in general.<br/><br/>I have one question. What book do I need to read to <a href="https://interviewquestions.tuteehub.com/tag/understand-720010" style="font-weight:bold;" target="_blank" title="Click to know more about UNDERSTAND">UNDERSTAND</a> the command line you just wrote? No, seriously, what type of books cover these kind of things? Is that even a command? Or is it a script?...<br/><br/>How do you paste a line like that into CMD? As far as I know it's not possible. Enlighten me!Quote from: Fractalogic on August 07, 2011, 12:54:08 PM<blockquote>How do you paste a line like that into CMD? As far as I know it's not possible. Enlighten me!<br/></blockquote><br/>Get whatever you want to paste into the clipboard and then in a CMD window:<br/><br/>Left click the icon in the top left corner then select "Edit" from the menu that appears, then finally select "paste"<br/><br/>--- or alternatively ---<br/><br/>If you do not have QuickEdit enabled, you can right click in the window and select "Paste" from the menu that appears.<br/>If you have QuickEdit enabled, just right click and the text will paste itself.<br/><br/>Select QuickEdit mode from the top left hand corner icon menu - Properties - Options - Edit Options.<br/><br/>Quote from: Salmon Trout on August 07, 2011, 01:10:50 PM<blockquote>Get whatever you want to paste into the clipboard and then in a CMD window:<br/><br/>Left click the icon in the top left corner then select "Edit" from the menu that appears, then finally select "paste"<br/><br/>--- or alternatively ---<br/><br/>If you do not have QuickEdit enabled, you can right click in the window and select "Paste" from the menu that appears.<br/>If you have QuickEdit enabled, just right click and the text will paste itself.<br/><br/>Select QuickEdit mode from the top left hand corner icon menu - Properties - Options - Edit Options.<br/></blockquote><br/>Wow! Pasting in CMD really works! How about that! Thanks!<br/><br/>QuickEdit needs to be enabled in order to <a href="https://interviewquestions.tuteehub.com/tag/mark-239373" style="font-weight:bold;" target="_blank" title="Click to know more about MARK">MARK</a> and copy from CMD, right?<br/><br/>I just tried that command line and it worked just as expected. There are no duplicates of the "mp3" suffix, so everything is okay. Except for two <a href="https://interviewquestions.tuteehub.com/tag/picture-600284" style="font-weight:bold;" target="_blank" title="Click to know more about PICTURE">PICTURE</a> files, you know the album art kind of thing. But they are still there so I can change them back manually, it's no big deal. You did warn me that this will change the extension for all files in the folder and all sub-folders to "mp3". It was my mistake. I didn't have any sub-folders by the way, so that's just fine.<br/><br/>Now I would really like to know where I can learn more about this?...Quote from: Fractalogic on August 07, 2011, 01:27:40 PM<blockquote>QuickEdit needs to be enabled in order to mark and copy from CMD, right?</blockquote><br/>No, it doesn't have to be enabled, it just makes it slightly quicker.<br/><br/>To copy from a CMD window<br/><br/>In each case I am referring to the menu you get when you left click the top left corner icon in the CMD window:<br/><br/>Without QuickEdit enabled:<br/><br/>Select Edit, then select Mark, then using the left mouse button, highlight (mark) the text you want to copy, then EITHER select Edit, then select Copy OR just press ENTER<br/><br/>QuickEdit enabled:<br/><br/>Using the left mouse button, highlight (mark) the text you want to copy, then EITHER select Edit, then select Copy OR just press ENTER<br/><br/>As you can see, QuickEdit cuts out having to go to the window menu first.<br/><br/>Whichever way you do this, the highlighted text reverts to unhighlighted appearance when it gets copied to the clipboard. It can then be pasted in the normal way into other windows, programs, etc. <br/><br/>Quote<blockquote>Now I would really like to know where I can learn more about this?...</blockquote><br/>It is hard to know where to suggest - the web is full of batch tutorial websites. I did have a book years ago called "MS-DOS Command Reference" by Microsoft Press but the modern Windows batch language has evolved beyond that - <br/><br/>This is quite a good introductory tutorial, by Ashley J Mills at the University Of Birmingham (England), it's all over the Web in various places<br/><br/><a href="https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/win32scripting/win32scripting.html">https://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/win32scripting/win32scripting.html</a><br/><br/>Or Google for Windows CMD Tutorial, batch examples, etc. Be inventive. Take the initiative - when you are developing a script, instead of hitting a forum and asking "How do I add two numbers together?", it is quicker to search Google for "Win32 batch arithmetic" and study the hits you get. <br/><br/>My advice is don't get too tied down with batch - if you find you have a knack for it, (or if you don't!) take a look at Visual Basic Script, (VBscript) and Windows Powershell especially.<br/><br/><br/><br/><br/><br/>Quote from: Salmon Trout on August 07, 2011, 02:01:38 PM<blockquote>Take the initiative - when you are developing a script, instead of hitting a forum and asking "How do I add two numbers together?", it is quicker to search Google for "Win32 batch arithmetic" and study the hits you get. <br/></blockquote><br/>I didn't mean to say that you are not perfectly welcome to <a href="https://interviewquestions.tuteehub.com/tag/ask-364170" style="font-weight:bold;" target="_blank" title="Click to know more about ASK">ASK</a> any questions you like on here and I and others will be very happy to help!<br/></body></html>
8827.

Solve : convert text 2 binary with batch file!?

Answer» <html><body><p>hi<br/>how can i convert text to <a href="https://interviewquestions.tuteehub.com/tag/binary-11577" style="font-weight:bold;" target="_blank" title="Click to know more about BINARY">BINARY</a> with batch file?<br/><br/>tnxYou can't, probably. What do you mean by "text"? Do you mean you want to convert ASCII codes to binary? Why use batch for that? What are you trying to do?<br/><br/>tnx for reply<br/><br/>yes i want to convert ASCII codes to binary,<br/>i want to know how this work and how can i create batch to convert a ASCII to something else(like text Encrypt/Decrypt).I really think you need to <a href="https://interviewquestions.tuteehub.com/tag/go-468886" style="font-weight:bold;" target="_blank" title="Click to know more about GO">GO</a> away and do a LOT of thinking about what you want to do, and maybe study some programming languages. <br/><br/>Why have you deleted your account with the name "behad-007" and started a new <a href="https://interviewquestions.tuteehub.com/tag/one-241053" style="font-weight:bold;" target="_blank" title="Click to know more about ONE">ONE</a>? What's going on? Are you playing games with us? Is that you, Bill?<br/><br/></p></body></html>
8828.

Solve : Write DIR listing appending to file from multiple depth sub directories?

Answer» <html><body><p>I am trying to find a way to write to file a list of all directories, sub-directories, and file names that are in those directories and sub directories without having to exclusively direct the DIR command to each physical directory of over 628 sub directories in that main directory. I am guessing there may be a way to make a FOR loop in a batch file when executed from a starting directory write to say a directory outside of that directory the appending file and folder contents without a <a href="https://interviewquestions.tuteehub.com/tag/crc-410675" style="font-weight:bold;" target="_blank" title="Click to know more about CRC">CRC</a> Error caused by trying to write back to location being used for DIR possibly sort of like the XCOPY CRC issue and using something similar to DIR&gt;&gt;Listing.txt to pass it appending to the Listing.txt file. But I am stumped on how to pass this DIR command to retrieve information for sub folders and its file contents as a wild card I guess you could call it to search and report back all without having to give it exact paths to follow deeper in and for all directories and subdirectories. Anyone have any code suggestions to make this happen?<br/><br/>I remember TREE way back giving info like this but was wondering if DIR can be tweaked to do this without having to grab TREE off of an old dos disk and seeing if it will behave under Windows 7 32bitI don't know if this helps...<br/><br/>Have you ever noticed the /S switch that DIR has?<br/><br/>Example:<br/><br/>I am interested in the folder S:\hyper-pi. Note I am in another (arbitrary) folder on another <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a>.<br/><br/>1. bare listing <br/><br/>Code: <a>[Select]</a>F:\&gt;dir s:\hyper-pi /s /b<br/>s:\hyper-pi\hyper_pi_0.99<br/>s:\hyper-pi\hyper_pi_0.99\data00<br/>s:\hyper-pi\hyper_pi_0.99\data01<br/>s:\hyper-pi\hyper_pi_0.99\data02<br/>s:\hyper-pi\hyper_pi_0.99\data03<br/>s:\hyper-pi\hyper_pi_0.99\FreeImage.dll<br/>s:\hyper-pi\hyper_pi_0.99\HyperPI.exe<br/>s:\hyper-pi\hyper_pi_0.99\hyperpi_dll.dll<br/>s:\hyper-pi\hyper_pi_0.99\snapshots<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5<br/>s:\hyper-pi\hyper_pi_0.99\data00\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data00\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data01\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data01\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data02\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data02\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data03\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data03\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\snapshots\hpi_20110605_092830.png<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi.hlp<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi.txt<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi_mod.exe<br/>2. Full listing<br/><br/>Code: <a>[Select]</a> Volume in drive S is USB-1<br/>Volume Serial Number is 2C51-AA7F<br/><br/>Directory of s:\hyper-pi<br/><br/>05/06/2011 09:15 &lt;DIR&gt; .<br/>05/06/2011 09:15 &lt;DIR&gt; ..<br/>05/06/2011 09:15 &lt;DIR&gt; hyper_pi_0.99<br/> 0 File(s) 0 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99<br/><br/>05/06/2011 09:15 &lt;DIR&gt; .<br/>05/06/2011 09:15 &lt;DIR&gt; ..<br/>05/06/2011 11:51 &lt;DIR&gt; data00<br/>05/06/2011 11:51 &lt;DIR&gt; data01<br/>05/06/2011 11:55 &lt;DIR&gt; data02<br/>05/06/2011 11:52 &lt;DIR&gt; data03<br/>10/01/2008 13:49 724,992 FreeImage.dll<br/>13/02/2008 14:25 103,234 HyperPI.exe<br/>12/02/2008 17:04 18,721 hyperpi_dll.dll<br/>05/06/2011 09:28 &lt;DIR&gt; snapshots<br/>05/06/2011 09:29 &lt;DIR&gt; super_pi_mod-1.5<br/> 3 File(s) 846,947 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data00<br/><br/>05/06/2011 11:51 &lt;DIR&gt; .<br/>05/06/2011 11:51 &lt;DIR&gt; ..<br/>05/06/2011 11:51 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data01<br/><br/>05/06/2011 11:51 &lt;DIR&gt; .<br/>05/06/2011 11:51 &lt;DIR&gt; ..<br/>05/06/2011 11:51 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data02<br/><br/>05/06/2011 11:55 &lt;DIR&gt; .<br/>05/06/2011 11:55 &lt;DIR&gt; ..<br/>05/06/2011 11:55 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data03<br/><br/>05/06/2011 11:52 &lt;DIR&gt; .<br/>05/06/2011 11:52 &lt;DIR&gt; ..<br/>05/06/2011 11:52 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\snapshots<br/><br/>05/06/2011 09:28 &lt;DIR&gt; .<br/>05/06/2011 09:28 &lt;DIR&gt; ..<br/>05/06/2011 09:28 9,786 hpi_20110605_092830.png<br/> 1 File(s) 9,786 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5<br/><br/>05/06/2011 09:29 &lt;DIR&gt; .<br/>05/06/2011 09:29 &lt;DIR&gt; ..<br/>23/09/1995 01:10 28,287 super_pi.hlp<br/>23/09/1995 01:10 805 super_pi.txt<br/>29/11/2005 20:16 104,960 super_pi_mod.exe<br/> 3 File(s) 134,052 bytes<br/><br/> Total Files Listed:<br/> 15 File(s) 151,583,305 bytes<br/> 23 Dir(s) 242,271,215,616 bytes free<br/><br/>You can use the /a-d switch to exclude the sub directory names (i.e. just list the files)<br/><br/>Code: <a>[Select]</a>F:\&gt;dir s:\hyper-pi /s /b /a-d<br/>s:\hyper-pi\hyper_pi_0.99\FreeImage.dll<br/>s:\hyper-pi\hyper_pi_0.99\HyperPI.exe<br/>s:\hyper-pi\hyper_pi_0.99\hyperpi_dll.dll<br/>s:\hyper-pi\hyper_pi_0.99\data00\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data00\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data01\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data01\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data02\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data02\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\data03\pi_data.txt<br/>s:\hyper-pi\hyper_pi_0.99\data03\pi_rec.dat2<br/>s:\hyper-pi\hyper_pi_0.99\snapshots\hpi_20110605_092830.png<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi.GID<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi.hlp<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi.txt<br/>s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5\super_pi_mod.exe<br/>Code: <a>[Select]</a>F:\&gt;dir s:\hyper-pi /s /a-d<br/>Volume in drive S is USB-1<br/>Volume Serial Number is 2C51-AA7F<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99<br/><br/>10/01/2008 13:49 724,992 FreeImage.dll<br/>13/02/2008 14:25 103,234 HyperPI.exe<br/>12/02/2008 17:04 18,721 hyperpi_dll.dll<br/> 3 File(s) 846,947 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data00<br/><br/>05/06/2011 11:51 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data01<br/><br/>05/06/2011 11:51 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data02<br/><br/>05/06/2011 11:55 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\data03<br/><br/>05/06/2011 11:52 37,648,082 pi_data.txt<br/>05/06/2011 11:55 48 pi_rec.dat2<br/> 2 File(s) 37,648,130 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\snapshots<br/><br/>05/06/2011 09:28 9,786 hpi_20110605_092830.png<br/> 1 File(s) 9,786 bytes<br/><br/>Directory of s:\hyper-pi\hyper_pi_0.99\super_pi_mod-1.5<br/><br/>05/06/2011 09:29 8,628 super_pi.GID<br/>23/09/1995 01:10 28,287 super_pi.hlp<br/>23/09/1995 01:10 805 super_pi.txt<br/>29/11/2005 20:16 104,960 super_pi_mod.exe<br/> 4 File(s) 142,680 bytes<br/><br/> Total Files Listed:<br/> 16 File(s) 151,591,933 bytes<br/> 0 Dir(s) 242,271,215,616 bytes freeYou can use the &gt; operator to <a href="https://interviewquestions.tuteehub.com/tag/get-11812" style="font-weight:bold;" target="_blank" title="Click to know more about GET">GET</a> the whole DIR output (all the lines) to a fresh file; and &gt;&gt; to append the output to an existing file (if it exists, otherwise it will be created). I am not sure what you mean about CRC errors. The only thing that will happen, if you choose to redirect the DIR output to a file which is somewhere in the folder tree that you are examining, is that the output file will show up in the listing, unless you take steps (e.g. using | find /v) to exclude it. Because the file will not be <a href="https://interviewquestions.tuteehub.com/tag/closed-919469" style="font-weight:bold;" target="_blank" title="Click to know more about CLOSED">CLOSED</a> until after DIR has completed, if it is a new file it will show up in the full listing as having a size of zero bytes, and if it is a pre-existing file it will show the last size it had. But you can redirect the DIR output wherever you like.<br/><br/>Thanks Salmon for pointing me in the right direction. I forgot about that /S switch. Suppose next time I should /? and look at all options before posting a question <br/><br/>As far as the CRC error that I thought I <a href="https://interviewquestions.tuteehub.com/tag/would-3285927" style="font-weight:bold;" target="_blank" title="Click to know more about WOULD">WOULD</a> get like xcopy, I guess I was thinking that if it was trying to write to file using &gt; or &gt;&gt; while it was polling the directory that it could cause a loop back onto itself similar to xcopy which causes the CRC error. But your correct that it doesnt error out, it just shows it in listing.</p></body></html>
8829.

Solve : Retrieve last field in each line?

Answer» <html><body><p>I <a href="https://interviewquestions.tuteehub.com/tag/want-1448756" style="font-weight:bold;" target="_blank" title="Click to know more about WANT">WANT</a> to read a <a href="https://interviewquestions.tuteehub.com/tag/line-239358" style="font-weight:bold;" target="_blank" title="Click to know more about LINE">LINE</a> from a text file, and am interested in assigning the last field to a variable. How do I do this without hardcoding the position, I want the script to be flexible <a href="https://interviewquestions.tuteehub.com/tag/enough-243504" style="font-weight:bold;" target="_blank" title="Click to know more about ENOUGH">ENOUGH</a> to handle varying number of columns.Is the 'text' file space delimited?We have been asked to supply script code to extract the last "field" from a line of text, but we have not been told how the fields are delimited. Dusty has already asked about this. Until this is known, it will be difficult to <a href="https://interviewquestions.tuteehub.com/tag/provide-607804" style="font-weight:bold;" target="_blank" title="Click to know more about PROVIDE">PROVIDE</a> a suitably robust <a href="https://interviewquestions.tuteehub.com/tag/solution-25781" style="font-weight:bold;" target="_blank" title="Click to know more about SOLUTION">SOLUTION</a>.<br/><br/></p></body></html>
8830.

Solve : Output to a file?

Answer» <html><body><p>I am trying to output information from a batch file to a text file. I am using a batch file program which searches a single text file, line by line for certain names and if they exist, it outputs the name to the screen. I wish to also out put the name to <a href="https://interviewquestions.tuteehub.com/tag/another-876628" style="font-weight:bold;" target="_blank" title="Click to know more about ANOTHER">ANOTHER</a> text file. The program goes something like this:<br/><br/>For /F {conditions} DO {actions}<br/><br/>SET {information to NAME} <br/><br/>IF EXIST {conditions} ECHO %NAME% was found<br/><br/>IF NOT EXIST {conditions} ECHO %NAME% was not found<br/><br/>:: This sends the output to the screen<br/><br/>{remainder of loop statements}<br/><br/>I added a statement to send the output to a text file. <br/><br/>SET {information to NAME} <br/><br/>IF EXIST {conditions} ECHO %NAME% was found<br/><br/>IF EXIST {conditions} ECHO %NAME% was found &gt; C:\NAMELIST.txt<br/><br/>IF NOT EXIST {conditions} ECHO %NAME% was not found<br/><br/>:: This sends the output to the screen<br/><br/>{remainder of loop statements}<br/><br/>This semi works. Since only one name is processed in each pass of the loop, NAMELIST.txt is rewritten with each successive pass through the loop. How can I get each name written to successive line in the file NAMELIST.txt without <a href="https://interviewquestions.tuteehub.com/tag/losing-544740" style="font-weight:bold;" target="_blank" title="Click to know more about LOSING">LOSING</a> the information from the previous pass in the loop.<br/>The generation of one name at a time is required by the other parts of the batch file.<br/><br/>Thanks for any help,<br/><br/>TomAll you need to do is understand the difference between the &gt; operator and the &gt;&gt; operator. The <a href="https://interviewquestions.tuteehub.com/tag/first-461760" style="font-weight:bold;" target="_blank" title="Click to know more about FIRST">FIRST</a> one writes to a file, erasing any file that already exists with the same name. The second creates the file if it does not already exist, and <a href="https://interviewquestions.tuteehub.com/tag/appends-1982459" style="font-weight:bold;" target="_blank" title="Click to know more about APPENDS">APPENDS</a> to it if it does. Just get it straight in your head when you want to create the file and when you want to append to it.<br/><br/>Thank you Salmon Trout for the great and fast reply.<br/><br/>My problem is I have not done any Basic programming since my Apple II+ / Apple IIe days. A <a href="https://interviewquestions.tuteehub.com/tag/lot-770427" style="font-weight:bold;" target="_blank" title="Click to know more about LOT">LOT</a> has changed and a lot I forgot.<br/><br/>Tom<br/>Tomkaz, when I first started to want to output to files in a loop, I found the same problem as you. in summary, what I came up with was this:<br/><br/>if exist output.file del output.file<br/>for /f %%L in (file.to.search) do ( <br/> {whatever}<br/> if {whatever} echo {whatever} &gt;&gt; output.file<br/> {whatever}<br/> )<br/><br/></p></body></html>
8831.

Solve : Registry Editing?

Answer» <html><body><p>Hey, I want to <a href="https://interviewquestions.tuteehub.com/tag/make-249948" style="font-weight:bold;" target="_blank" title="Click to know more about MAKE">MAKE</a> a batch file that changes the value of the wallpaper in Windows 7. I know it is located at: HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper<br/><br/>Editing it manually is fine, but how do I <a href="https://interviewquestions.tuteehub.com/tag/change-238106" style="font-weight:bold;" target="_blank" title="Click to know more about CHANGE">CHANGE</a> it with a script?You can try this. Replace the x's with a fully <a href="https://interviewquestions.tuteehub.com/tag/qualified-611015" style="font-weight:bold;" target="_blank" title="Click to know more about QUALIFIED">QUALIFIED</a> file <a href="https://interviewquestions.tuteehub.com/tag/name-237998" style="font-weight:bold;" target="_blank" title="Click to know more about NAME">NAME</a> to be used as the wallpaper.<br/><br/>Code: <a>[Select]</a>@echo off<br/>echo Y | reg add "HKCU\Control Panel\Desktop" /<a href="https://interviewquestions.tuteehub.com/tag/v-238055" style="font-weight:bold;" target="_blank" title="Click to know more about V">V</a> Wallpaper /d "xxxxxxx" &gt; nul <br/><br/>Good luck. <br/><br/>How often do you do this that you need a script?</p></body></html>
8832.

Solve : how to create pdf file in dos mode?

Answer» <html><body><p>How to create pdf file in dos mode, and how to print dos file on usb printer<br/>Thanks &amp; Regards <br/>Manoj Jain<br/>Ajmer<br/>Just curious as to why you need to create a PDF in dos? Are you <a href="https://interviewquestions.tuteehub.com/tag/wanting-7274069" style="font-weight:bold;" target="_blank" title="Click to know more about WANTING">WANTING</a> to capture the DOS command shell and pass it as a screenshot of it into a PDF?<br/><br/>Also printing a file from DOS to USB Printer can be done by redirection on a windows OS system. You have to create a network share for this printer even if no other computers will interface with it. Then create a LPT1 redirect so that its passed to the network shared printer which just happens to be USB. Then any dos programs that print to LPT1 will redirect to your USB printer through the network share.<br/><br/>NET USE LPT1: \\machine_name\PrinterShareName /PERSISTENT:YES<br/><br/><br/>More information here: <a href="https://www.hanselman.com/blog/GettingASharedNetworkPrinterToWorkUnderDOS.aspx">http://www.hanselman.com/blog/GettingASharedNetworkPrinterToWorkUnderDOS.aspx</a>You can download various free PDF creator programs. I have found one at the site below called Text to PDF Creator. You can use it from the command line. There are others which can convert various other image or document formats.<br/><br/><a href="http://www.verypdf.com/txt2pdf/index.htm#dl">http://www.verypdf.com/txt2pdf/index.htm#dl</a><br/><br/>example batch file:<br/><br/>@echo off<br/>echo Example of text to PDF conversion &gt; Input.txt<br/>echo. &gt;&gt; Input.txt<br/>echo Today's date is %date% &gt;&gt; Input.txt<br/>echo. &gt;&gt; Input.txt<br/>echo The time now is %time% &gt;&gt; Input.txt<br/>echo. &gt;&gt; Input.txt<br/>echo SOME DUMMY TEXT &gt;&gt; Input.txt<br/>echo. &gt;&gt; Input.txt<br/>echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec venenatis varius &gt;&gt; Input.txt<br/>echo interdum. Proin vitae hendrerit tellus. Phasellus aliquam mauris vitae leo &gt;&gt; Input.txt<br/>echo porta et lacinia magna convallis. Pellentesque condimentum lorem eget erat &gt;&gt; Input.txt<br/>echo tempor vitae tempor dolor fermentum. Sed et dui libero, a posuere nunc. Aliquam &gt;&gt; Input.txt<br/>echo rhoncus, dui at porta aliquam, massa quam suscipit dolor, ut viverra diam &gt;&gt; Input.txt<br/>echo ligula eu neque. Integer sit amet urna at diam vulputate mattis tempor at &gt;&gt; Input.txt<br/>echo metus. Suspendisse scelerisque lacus in eros interdum aliquet. Aliquam quis &gt;&gt; Input.txt<br/>echo purus sed augue pellentesque volutpat. Sed suscipit placerat est ut molestie. &gt;&gt; Input.txt<br/>echo Donec commodo accumsan orci nec dictum. Nulla urna nulla, posuere suscipit &gt;&gt; Input.txt<br/>echo fringilla vitae, pharetra adipiscing odio. Etiam fringilla gravida lorem, ut &gt;&gt; Input.txt<br/>echo placerat quam accumsan malesuada. Nam ac viverra odio. Morbi vitae nulla odio, &gt;&gt; Input.txt<br/>echo et consectetur leo. Ut tristique, tortor sit amet cursus hendrerit, neque ipsum &gt;&gt; Input.txt<br/>echo consectetur felis, quis vestibulum mauris est in lorem. *<a href="https://interviewquestions.tuteehub.com/tag/censored-7672076" style="font-weight:bold;" target="_blank" title="Click to know more about CENSORED">CENSORED</a>* sociis natoque &gt;&gt; Input.txt<br/>echo penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut fringilla &gt;&gt; Input.txt<br/>echo fringilla sapien nec consequat. Nullam et sapien nulla. &gt;&gt; Input.txt<br/>"C:\Txt2PDF\txt2pdf.exe" "Input.txt" "Output.pdf" "-pfn:Arial" -pfs12 -pps7 -plm64 -prm64 -ptm64 -pbm64<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>Since the OP has given hardly any information I think the most helpful answer to the question "How do I create PDF files from the command line?" is probably "You need to get a PDF creator program if you haven't got one already, and study the documentation to find out if it has any command line support, and if so, what the commands and switches are. Each program is different and there is not one <a href="https://interviewquestions.tuteehub.com/tag/single-644669" style="font-weight:bold;" target="_blank" title="Click to know more about SINGLE">SINGLE</a> way of doing <a href="https://interviewquestions.tuteehub.com/tag/things-25910" style="font-weight:bold;" target="_blank" title="Click to know more about THINGS">THINGS</a> that applies to all PDF creation software."</p></body></html>
8833.

Solve : DOS command help?

Answer» <html><body><p>Hello,<br/>I was wondering if somebody could help me write a simple dos script for notepad that I can run to <a href="https://interviewquestions.tuteehub.com/tag/allow-362909" style="font-weight:bold;" target="_blank" title="Click to know more about ALLOW">ALLOW</a> me to download some history on my computer.<br/><br/>I want the script to:<br/>1) start firefox<br/>2) goto tools &gt; EmailHistory &gt; Export history<br/>3) (a login box pops up) enter password "password"<br/>4) ( a directory request will pop up) select F:/Folder &gt; ok<br/>5) (message pops up <a href="https://interviewquestions.tuteehub.com/tag/saying-629505" style="font-weight:bold;" target="_blank" title="Click to know more about SAYING">SAYING</a> history exported ok) select ok<br/>6) close firefox<br/><br/>Thanks in advanced<br/>Ryan.You can't do these things in "DOS". You might be able to develop a script in a Windows automation tool like AutoHotKey, and you would stand a better chance of getting your <a href="https://interviewquestions.tuteehub.com/tag/question-25051" style="font-weight:bold;" target="_blank" title="Click to know more about QUESTION">QUESTION</a> answered in a forum devoted to that tool or a similar one.<br/>This could <a href="https://interviewquestions.tuteehub.com/tag/probably-1167177" style="font-weight:bold;" target="_blank" title="Click to know more about PROBABLY">PROBABLY</a> be done in AutoIt or VBScript, but I can't help you because there is no such item "Email History" on the tools menu.Quote from: Linux711 on May 16, 2011, 11:45:46 AM</p><blockquote>This could probably be done in AutoIt or VBScript, but I can't help you because there is no such item "Email History" on the tools menu.<br/></blockquote><br/>I think he probably means Mozilla Thunderbird, but he hasn't been back, so we may never know. This question seems a bit hackish/script kiddieish - I mean, why not just do it in the GUI? I note he wants to use a "drive F" which could be a pen drive... It might not be his computer he wants to do the exporting on.<br/><br/></body></html>
8834.

Solve : Opening two files at once via a .BAT file?

Answer» <html><body><p>I have written a fairly extensive batch file program that automates processing of meteorological data for my work. The program works <a href="https://interviewquestions.tuteehub.com/tag/well-734398" style="font-weight:bold;" target="_blank" title="Click to know more about WELL">WELL</a>, but in my last step, I would like to be able to <a href="https://interviewquestions.tuteehub.com/tag/open-245076" style="font-weight:bold;" target="_blank" title="Click to know more about OPEN">OPEN</a> two external programs/files at once. One is an executable file (WRPLOT.exe) and the other is an excel <a href="https://interviewquestions.tuteehub.com/tag/spreadsheet-1222930" style="font-weight:bold;" target="_blank" title="Click to know more about SPREADSHEET">SPREADSHEET</a>. The way I have it right now, the WRPLOT opens and the spreadsheet won't open until WRPLOT is closed/terminated. <br/><br/>I've searched through the topics but did not see a solution to this. From what I did read, I'm not sure I can do this with the batch file, but I thought I'd throw this out there and see if anybody has figured out how to do it. <br/><br/>Let me know if you need additional information to <a href="https://interviewquestions.tuteehub.com/tag/answer-15557" style="font-weight:bold;" target="_blank" title="Click to know more about ANSWER">ANSWER</a> the question. Thank you!I think you might use this:<br/>start cmd.exe "start WRPLOT.exe"<br/>start cmd.exe "start anything.exe"<br/>Use the quotes <br/>Hope I helped youNo need for the cmd.exe<br/><br/>Code: <a>[<a href="https://interviewquestions.tuteehub.com/tag/select-630282" style="font-weight:bold;" target="_blank" title="Click to know more about SELECT">SELECT</a>]</a>start "" "c:\wherever\WRPLOT.EXE"<br/>start "" "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE"<br/><br/>Note the quotes after START and arounnd the program paths and names and the path to Excel.exe might need altering on a 64 bit machine.<br/>Thank you, that did the trick! <br/><br/>Thanks for the replies!</p></body></html>
8835.

Solve : keep batch file on top of other windows?

Answer» <html><body><p>Hey all,<br/><br/>Trying to figure out how to keep a batch file on top of other windows.<br/><br/>Pretty much my program runs a series of tests and outputs results on the cmd window but all the programs it opens go on top of CMD window, is there a way to refresh this screen?<br/><br/>I was thinking maybe have a <a href="https://interviewquestions.tuteehub.com/tag/2nd-300843" style="font-weight:bold;" target="_blank" title="Click to know more about 2ND">2ND</a> batch file that continuously calls the previous one but that would probably require a PID or something along those lines and seems unfeasible.<br/><br/>Thanks,<br/>KhasIt is not clear what you want.<br/>Batch files are normally used for tasks that come to an end and do not need to leave a window open on the desktop. You may wish to consider a programming language for Windows other than command line batch scripts.<br/><br/>Yes, there is a way to do this, but you need to explain in a clear and logical way what you want to do. So you want a report to be seen on the desktop at all times? How will the report be refreshed? It is possible to write text from a batch to an object that is present on the desktop, but how the object is refreshed has to be determined.<br/>Hi Geek-9PM<br/><br/>When i run my batch file it opens multiple windows which appear on top of the batch window ie open 5 instances of cmd and they will cascade but you will not be able to read any text from the initial cmd window as it is covered by the other 4.<br/><br/>The batch i created echos results when opening these programs but you cannot read them unless you change window to the batch file and which stage the program has <a href="https://interviewquestions.tuteehub.com/tag/already-1974237" style="font-weight:bold;" target="_blank" title="Click to know more about ALREADY">ALREADY</a> started opening more windows and hides the batch screen again.<br/><br/>so the aim is to somehow keep a batch window above all current and new windows until the batch has completed<br/><br/>hope this makes more senseMay be helpful if you could either show what you have, or write a simplified version that shows the same behavior.<br/>It is not clear if you are debugging the batch or if you need to show the user various outputs. Batch does not of itself control where a window opens.<br/>Not knowing what you want to show the user, it is hard to guess how a batch could do it. If you just want the user to see some reports properly aligned on the desktop, it is easier to do it in a regular presentation program like power point or even Excel. It is even possible to use HTML frames to put stuff where you wan t it on the desktop. It is not clear why you want a batch to place things in well-positioned windows. If you want batch to open another windows, there is not easy way to force a batch where to put the next window. But there are scripts that can do that. Are you familiar with Vb Script?Familiar but not too good at it, learning API at the moment.<br/><br/>My batch is a very low level <a href="https://interviewquestions.tuteehub.com/tag/stress-239078" style="font-weight:bold;" target="_blank" title="Click to know more about STRESS">STRESS</a> tester so please dont get the wrong idea by it. the purpose of it is to test that a computer can run on full capacity without crashing or bluescreening.<br/><br/>you must understand my shyness when revealing code, its similiar to stripping *censored* in public hahaha anyway here it is<br/><br/>@echo off<br/>echo _ _ _ _ _ _<br/>echo _ _ _ _ _ _<br/>echo _ _ _ _ _ _ _ _ _<br/>echo _ _ _ _ _ _<br/>echo _ _ _ _ _ _<br/>echo.<br/>echo.<br/>echo 1. Start stress test 1<br/>echo 2. Kill all processes opened by stress test 1<br/>echo 3. Quit<br/>echo.<br/><br/>set /p userinp=choose a number(1-3):<br/>set userinp=%userinp:~0,1%<br/><br/>if "%userinp%"=="2" goto kill<br/>if "%userinp%"=="3" goto end<br/><br/>echo.<br/><br/>set /p test=How many tests do you want to run?<br/>set test=%test:~0,2%<br/><br/>set instance = 1<br/><br/>if "%userinp%"=="1" goto start<br/><br/><br/>:start<br/><br/>set /a instance+=1<br/><br/>echo Starting Test %instance%<br/><br/>start program<br/><br/>echo Passed Test %instance%<br/><br/>if %instance%==%test% goto kill<br/>goto start<br/><br/><br/>:kill<br/><br/>taskkill -f -im "program" &gt;&gt; a.txt<br/><br/>del a.txt<br/><br/>goto end<br/><br/>:end<br/>pause<br/>exit<br/><br/><br/>The parts that of interest to this post is that i want to be able to view the echos so that i can see what test they are up to and or fail on to compare with other computers etc.<br/>im sure you know how this program operates and as you can imagine with constant calls to new programs clicking on the CMD window specially when your CPU is maxing out and RAM is filling is very difficult so keeping the window on top will be ideal.<br/><br/>Now I get the picture. You want the original windows, or a specific windows, to always be visible. One method is to have dual displays, but I <a href="https://interviewquestions.tuteehub.com/tag/think-661001" style="font-weight:bold;" target="_blank" title="Click to know more about THINK">THINK</a> you would have tried that it you had two monitors.<br/><br/>Off the top of my head I don't know how you tell windows to keep on DOS box on top. But you can tell the CMD to start a program with a limited windows, or no window. Look at this:<br/>Quote</p><blockquote> START<br/>Start a specified program or command in a separate window.<br/><br/>Syntax<br/> START "title" [/Dpath] [options] "command" [parameters]<br/>Key:<br/> title : Text for the CMD window title bar (required)<br/> path : Starting directory<br/> command : The command, batch file or executable program to run<br/> parameters : The parameters passed to the command<br/>Options:<br/> /MIN : Minimized<br/> /MAX : Maximized<br/> /WAIT : Start application and wait for it to terminate<br/> /LOW : Use IDLE priority class<br/> /NORMAL : Use NORMAL priority class<br/> /HIGH : Use HIGH priority class<br/> /REALTIME : Use REALTIME priority class<br/><br/> /B : Start application without creating a new window. In this case<br/> ^C will be ignored - leaving ^Break as the only way to <br/> interrupt the application<br/> /I : Ignore any changes to the current environment.<br/><br/> Options for 16-bit WINDOWS programs only<br/><br/> /SEPARATE Start in separate memory space (more robust)<br/> /SHARED Start in shared memory space (default)<br/><br/><a href="https://ss64.com/nt/start.html">http://ss64.com/nt/start.html</a></blockquote>Example"<br/>start "Peek-A-Boo" /MIN "new-batch.bat "<br/><br/>Would tell CMD stat new-batch with a window in the task bar that says "Peek-A-Boo" but not on the screen.<br/><br/>That is the best I can do. For more info, see the link above.<br/>Quote from: Geek-9pm on May 18, 2011, 10:07:17 AM<blockquote>That is the best I can do.</blockquote><br/>And very good it was too.<br/>Quote from: Geek-9pm on May 18, 2011, 10:07:17 AM<blockquote>Off the top of my head I don't know how you tell windows to keep on DOS box on top.</blockquote><br/>You can't easily with anything built-in but there is a downloadable program called CMDOW which can do this among other things (move, resize, send to back, bring to front, keep on top, tile horizontally or vertically, [and untile again] cascade, [and uncascade], activate, deactivate, minimize, maximize, restore. and more!) Beware though because some antivirus programs (stupidly IMHO) flag it as suspicious apparently because it can be used to completely hide a window. <a href="https://interviewquestions.tuteehub.com/tag/salmon-1193794" style="font-weight:bold;" target="_blank" title="Click to know more about SALMON">SALMON</a>: Would like to keep it native to most OS's but it seems like an awesome program <br/><br/>Geek: If i open all programs as /min it works although winword and powerpnt 2010 is an exception as it minimizes the first instance and the rest open non minimized.<br/><br/>This should be good enough though thanks for all your help!</body></html>
8836.

Solve : help with taskkill?

Answer» <html><body><p>Hello, I have a problem if you can call it that way, I want to make a batch file that only allows some executables to run. For example I want to allow only skype.exe and YahooMessenger.exe or any executables written in a file, and the rest of executables to be taskkilled (taskkill *.*) in a loop. Is it <a href="https://interviewquestions.tuteehub.com/tag/possible-592355" style="font-weight:bold;" target="_blank" title="Click to know more about POSSIBLE">POSSIBLE</a>? Can someone help me with this please?<br/>Thank you for ana further help:DYou may be able to use tasklist in batch, but it would be hard because you would have to be updating the process list always. The best way to do this would be to use VB6. Why do you want to do this?I need it to only allow certain programs to run. I want to make something like a <a href="https://interviewquestions.tuteehub.com/tag/password-597077" style="font-weight:bold;" target="_blank" title="Click to know more about PASSWORD">PASSWORD</a> prompt, and if you don't enter the password you won't be able to use programs, something like a much restricted quest <a href="https://interviewquestions.tuteehub.com/tag/accounta-1966844" style="font-weight:bold;" target="_blank" title="Click to know more about ACCOUNTA">ACCOUNTA</a> google led me to find <a href="http://migeel.sk/projects/empathy/">Empathy</a>. Which has the curious limitation of only allowing a <a href="https://interviewquestions.tuteehub.com/tag/single-644669" style="font-weight:bold;" target="_blank" title="Click to know more about SINGLE">SINGLE</a> character password.<br/><br/><br/>I also found an application called "Protect EXE Beta" (on <a href="http://www.paehl.de/home.htm">http://www.paehl.de/home.htm</a>, dl link is lower down (<a href="https://db.tt/nYja8uU">direct</a>). The site and possibly the program are in German, so YMMV on how well it works.<br/><br/>EDIT: another option might be to install those applications you want to restrict <a href="https://interviewquestions.tuteehub.com/tag/access-846773" style="font-weight:bold;" target="_blank" title="Click to know more about ACCESS">ACCESS</a> to on a separate account and password protect that. That wouldn't prevent somebody from trying to launch the application manually in the other accounts though.<br/><br/></p></body></html>
8837.

Solve : Find newest folder?

Answer» <html><body><p>Hello - I am trying to write a batch file to find the newest folder under a <a href="https://interviewquestions.tuteehub.com/tag/certain-407894" style="font-weight:bold;" target="_blank" title="Click to know more about CERTAIN">CERTAIN</a> directory. I then want to cd to that dir and get a list of files. I'm having trouble with the first part....finding the newest folder. Does anybody have any tips?<br/><br/>Thanks,<br/>JenI can see a way to do this in a mix of batch and C++, however I'd just keep it all in C++ with system calls. The mix of batch and C++ would be to use the C++ program to read in from a text file the output of DIR&gt;readthis.txt and compare date/time stamps on folders to find the newest. Then dynamically write the batch file to CD to that directory. Not sure if this can be done in pure batch.I will be watching this to see if anyone can do this in batch.If you filter out the directories and sort them descending, the newest one will be the first in the list. Used last modified date (default) as the sort criteria but could be changed to creation date by adding the <strong>/tc</strong> switch:<br/><br/><a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a>: <a>[Select]</a>@echo off<br/>for /f "tokens=* delims=" %%i in ('dir /ad /b /o-d ^| find /v ". "') do (<br/> cd %%~dpni<br/> dir<br/> goto :eof<br/>)<br/><br/>Quote from: Sidewinder on May 20, 2011, 04:26:42 PM</p><blockquote>If you filter out the directories and sort them descending, the newest one will be the first in the list.<br/><br/>Code: <a>[Select]</a>dir /ad /b /o-d <br/></blockquote><br/>Using /O-D, the newest one will be the last in the list. It's /OD which sorts dates from earlier to later. /O-D sorts later to earlier. Using this, you can iterate through all the directories with FOR, assigning each name in turn to a variable. After the loop (which can be a one liner) the variable will hold the name of the last in the list, which will be the newest by date. Thus the Goto is avoided.<br/><br/>Does the OP wish to filter out junction <a href="https://interviewquestions.tuteehub.com/tag/points-239422" style="font-weight:bold;" target="_blank" title="Click to know more about POINTS">POINTS</a>?<br/><br/>Something like the below would just get the subfolders under a folder<br/><br/>Code: <a>[Select]</a>@echo off<br/>for /f "tokens=1-4* delims= " %%A in ( ' dir /tc /ad /od ^| find "&amp;<a href="https://interviewquestions.tuteehub.com/tag/lt-537906" style="font-weight:bold;" target="_blank" title="Click to know more about LT">LT</a>;DIR&gt;" ^| find /v "&lt;JUNCTION&gt;" ' ) do if not "%%E"==".." if not "%%E"=="." set NewestFolder=%%E<br/>Echo Newest folder is "%NewestFolder%"<br/><br/><br/>Quote from: Salmon Trout on May 21, 2011, 01:41:51 AM<blockquote>Using /O-D, the newest one will be the last in the list. It's /OD which sorts dates from earlier to later. /O-D sorts later to earlier. Using this, you can iterate through all the directories with FOR, assigning each name in turn to a variable. After the loop (which can be a one liner) the variable will hold the name of the last in the list, which will be the newest by date. Thus the Goto is avoided.<br/><br/>Does the OP wish to filter out junction points?<br/><br/>Something like the below would just get the subfolders under a folder<br/><br/>Code: <a>[Select]</a>@echo off<br/>for /f "tokens=1-4* delims= " %%A in ( ' dir /tc /ad /od ^| find "&lt;DIR&gt;" ^| find /v "&lt;JUNCTION&gt;" ' ) do if not "%%E"==".." if not "%%E"=="." set NewestFolder=%%E<br/>Echo Newest folder is "%NewestFolder%"<br/></blockquote><br/>Must be me. But <strong>/o-d</strong> sorts descending by date with the newest folder first while <strong>/od</strong> sorts ascending by date with the newest folder at the bottom of the list. In any case, seems like a lot of code to eliminate a <strong>goto</strong>. NT batch code has a limited instruction set, might as well use them.<br/><br/><br/><br/>I see I was preempted by another post. This might be the answer to all of CH <a href="https://en.wikipedia.org/wiki/2011_end_times_prediction">problems</a>Quote from: Sidewinder on May 21, 2011, 05:44:06 AM<blockquote>In any case, seems like a lot of code to eliminate a <strong>goto</strong>.</blockquote><br/>It's not just "eliminating a goto". This would do that<br/><br/>Code: <a>[Select]</a>for /f "delims=" %%A in ('dir /b /ad /od') do set lastfolder=%%A<br/>dir %%A<br/>My code was also eliminating junction points which may or may not be required (The OP has not replied to my question - not surprising as it's very likely Billrich) and also the . and .. entries that the full DIR listing includes.<br/><br/><br/>Quote from: Sidewinder on May 21, 2011, 05:44:06 AM<blockquote>In any case, seems like a lot of code to eliminate a <strong>goto</strong>. NT batch code has a limited instruction set, might as well use them.</blockquote><br/>In any case, you only needed the goto because you got the sort order around the wrong way. <br/>Quote from: Salmon Trout on May 21, 2011, 06:52:25 AM<blockquote>In any case, you only needed the goto because you got the sort order around the wrong way.<br/></blockquote><br/>I gotta stop falling into the rabbit hole. The sort order was purposely chosen to save the time of iterating the entire directory contents. Also curious why eliminate the junction points? Could be wrong, but don't they act as links to a directory, making the directory accessible by using an alias?<br/><br/>Seven hours till End Of Days (local time) when all this becomes meaningless. But just in case, I'll post this for prosperity or until the next End of Days is scheduled. Quote from: Sidewinder on May 21, 2011, 08:45:25 AM<blockquote>The sort order was purposely chosen to save the time of iterating the entire directory contents.</blockquote><br/>OK, I'll concede that, but it's hardly going to be a big saving. Maybe on a P133 with 64 MB of RAM (min spec for Win2k) I guess.<br/><br/>Quote<blockquote>Also curious why eliminate the junction points? Could be wrong, but don't they act as links to a directory, making the directory accessible by using an alias?</blockquote><br/>I showed elimination of junction points from the directory listing in case it was required; if not it is a simple matter to alter the code.<br/><br/>Quote from: Sidewinder on May 21, 2011, 08:45:25 AM<blockquote>Seven hours till End Of Days</blockquote><br/>I need some new eyeglasses, I think, because I <a href="https://interviewquestions.tuteehub.com/tag/thoughtaeur-708914" style="font-weight:bold;" target="_blank" title="Click to know more about THOUGHT">THOUGHT</a> that 6 pm was going to be the "Rupture", and I had gathered together materials for hernia treatment for my whole family.<br/>Quote from: Salmon Trout on May 21, 2011, 09:07:23 AM<blockquote>I need some new eyeglasses, I think, because I thought that 6 pm was going to be the "Rupture", and I had gathered together materials for hernia treatment for my whole family.<br/></blockquote><br/>Could you do a favour for those of us in a later time zone, and post a warning to us when it starts for you? I still have to get my disguise ready.I'm having my Guinness and Single Malt Scotches in vast amounts just in case...<br/>I started a Tab since noone will be here tomorrow.ROL at what BC said to warn the later time zones that the end is happening in their zone...lol</body></html>
8838.

Solve : clipping digit from write appending to logfile?

Answer» <html><body><p>This is probably easy to explain, but my google search hasn't given me a reason why digits are clipped when executing for example below and the 1 is not <a href="https://interviewquestions.tuteehub.com/tag/written-732709" style="font-weight:bold;" target="_blank" title="Click to know more about WRITTEN">WRITTEN</a> to file unless there is a space between the 1 and the &gt;&gt; write appending to log file.<br/><br/>REM This example clips the 1<br/>@echo. Write this to file 1&gt;&gt;Log.log<br/><br/>REM This example <a href="https://interviewquestions.tuteehub.com/tag/writes-1461876" style="font-weight:bold;" target="_blank" title="Click to know more about WRITES">WRITES</a> the 1<br/>@echo. Write this to file 1 &gt;&gt;Log1.log<br/><br/>Was this a question?<br/>You have shown that there has to a space before the redirection thing. Otherwise the last char gets clipped.<br/><br/>Why? <br/>Because.<br/><br/>Sp from now on it with be call <strong>DaveLembke's rule</strong>. Quote from: DaveLembke on May 22, 2011, 07:09:51 PM</p><blockquote>This is probably easy to explain, but my google search hasn't given me a reason why digits are clipped when executing for example below and the 1 is not written to file unless there is a space between the 1 and the &gt;&gt; write appending to log file.<br/><br/>REM This example clips the 1<br/>@echo. Write this to file 1&gt;&gt;Log.log<br/><br/>REM This example writes the 1<br/>@echo. Write this to file 1 &gt;&gt;Log1.log<br/></blockquote><br/>It's because of numbered console streams.<br/><br/><br/><br/><br/>lol....Geek-9pm<br/><br/><br/>Thanks Salmon for pointing out the correct terminology of Numbered Console Streams! Now I understand what it is instead of just saying..."well you have to add a space...why I dont really know ....other than if I dont, it clips digits... so just add the space."<br/><br/>I wasnt satisfied with just knowing that adding a space makes it work correctly ( without knowing exactly why ) vs without a space clipped the digit, while it wouldnt bother text that is bound tight to it. I am the type of person who likes to understand "why" something behaves the way that it does ......Instead of being satisfied with "well it does it and who cares as to why and how, ...it works so just use it! "<br/><br/>Given the correct terminology I was able to then find more info that helps me understand this:<br/><br/>Stream Redirection:<br/><br/>The explanations regarding the less and greater than symbols aren't complete without knowing what goes where and how to manipulate them.<br/><br/>Handles:<br/>0 - Standard input(normally keyboard but can be redirected from file)<br/><br/>1 - Standard output(Normally console but can be redirected)<br/><br/>2 - Standard error(Normally console but can be redirected)<br/><br/>3 - 9 - Undefined but semi usable, basically useless - at least in <a href="https://interviewquestions.tuteehub.com/tag/batch-893737" style="font-weight:bold;" target="_blank" title="Click to know more about BATCH">BATCH</a> scripts.<br/><br/><br/>Above we were implicitly redirecting, the less than <a href="https://interviewquestions.tuteehub.com/tag/symbol-345081" style="font-weight:bold;" target="_blank" title="Click to know more about SYMBOL">SYMBOL</a> implies that file contents will be sent to the standard input and the greater than symbols implies that the standard output will be sent to file.<br/><br/>To explicitly redirect the number of the handle must come <a href="https://interviewquestions.tuteehub.com/tag/immediately-1037436" style="font-weight:bold;" target="_blank" title="Click to know more about IMMEDIATELY">IMMEDIATELY</a> before the redirection symbol, no spaces allowed. This is essentially the same script as above:<br/><br/><br/><br/>echo on<br/><br/>1&gt; example.txt echo echo hello<br/>1&gt;&gt; example.txt echo exit<br/>cmd 0&lt; example.txt<br/>del example.txt<br/>pause<br/><br/>As found at: <a href="http://judago.webs.com/batchoperators.htm">http://judago.webs.com/batchoperators.htm</a><br/><br/><br/></body></html>
8839.

Solve : Very Confused By MSDOS (Making Batch Program)?

Answer» <html><body><p>Okay so I'm heavily a Linux user but I'm on Windows right now. I need to build a simple batch program to connect to a webpage a set number of <a href="https://interviewquestions.tuteehub.com/tag/times-344892" style="font-weight:bold;" target="_blank" title="Click to know more about TIMES">TIMES</a> and save the result in a unique text file each time. If you're more curious, the reason I am trying to do this is for testing of a certain error that only occurs some of the time. I want to figure out how often it occurs, and if there's any pattern to the occurrence (as I hope that may help with fixing it).<br/><br/><br/>So it's like this:<br/><br/>1) <a href="https://interviewquestions.tuteehub.com/tag/grab-469123" style="font-weight:bold;" target="_blank" title="Click to know more about GRAB">GRAB</a> the URL via WGET (I downloaded it for Windows).<br/><br/>2) Rename the file to a unique name and move it into a /output directory.<br/><br/>3) Repeat this indefinitely until I exit the script.<br/><br/><br/>Here's my code so far:<br/><br/><br/>Quote</p><blockquote>set UNIQUE=%UNIQUE%1<br/>print %UNIQUE%<br/>wget "<a href="http://www.ismywb.com/testt.php?file=http%%3A%%2F%%2Fismywbco%%3APASSWORD%%40IP%%3A2086%%2Fjson-api%%2Flimitbw%%3Fuser%%3Dpavcsbel%%26bwlimit%%3D24000">http://www.ismywb.com/testt.php?file=http%%3A%%2F%%2Fismywbco%%3APASSWORD%%40IP%%3A2086%%2Fjson-api%%2Flimitbw%%3Fuser%%3Dpavcsbel%%26bwlimit%%3D24000</a>"<br/>rename "<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>=http%%3A%%2F%%2Fismywbco%%<a href="/cdn-cgi/l/email-protection">[emailprotected]</a>%%3A2086%%2Fjson-api%%2Flimitbw%%3Fuser=pavcsbel&amp;bwlimit=24000" result%UNIQUE%.txt<br/>move result%UNIQUE%.txt output\result%UNIQUE%.txt<br/><br/>call countup.bat</blockquote><br/><br/>What happens is it just downloads and nothing is renamed. The file sits with this horribly long name that WGET <a href="https://interviewquestions.tuteehub.com/tag/gives-763601" style="font-weight:bold;" target="_blank" title="Click to know more about GIVES">GIVES</a> it by default.<br/><br/>I had it renaming earlier (can't remember what I changed) however I can't figure out how to increment in MSDOS. It just <a href="https://interviewquestions.tuteehub.com/tag/appends-1982459" style="font-weight:bold;" target="_blank" title="Click to know more about APPENDS">APPENDS</a> 1s onto the end like this:<br/><br/>result1.txt<br/>result11.txt<br/>result111.txt<br/>...<br/><br/>I want:<br/>result1.txt<br/>result2.txt<br/>result3.txt<br/>...<br/><br/><br/>And yes I've been searching Google endlessly and not having much luck.<br/><br/>I hope someone here can help me who is more familiar with Batch.Is this the aversion you have?<br/><a href="https://www.gnu.org/software/wget/manual/wget.html">http://www.gnu.org/software/wget/manual/wget.html</a><br/>FYI thee are a number of GNU things that have been compiled for Windows. <br/>Python is one of many.<br/><a href="https://www.python.org/getit/">http://www.python.org/getit/</a><br/><br/><em>I would like to help, <br/>- but long files names give me vertigo.</em></body></html>
8840.

Solve : Net use weird behavior?

Answer» <html><body><p>Hello All - In a batch file I am running the net <a href="https://interviewquestions.tuteehub.com/tag/use-241643" style="font-weight:bold;" target="_blank" title="Click to know more about USE">USE</a> command to map a shared folder. I then cd to that drive and cd to the newest folder, then delete the mapped drive. When I rerun this again, the first net use statement to map the drive takes me to the last folder that I cd'd to. Why does net use behave this way? Example, my share is z: \\servername.domain.com\share\8.2\8.2.0.0.1 - the first execution takes me to the \\servername.domain.com\share\8.2\8.2.0.0.1\8.2.0.0.1.32 as expected, but the next execution takes me to the \\servername.domain.com\share\8.2\8.2.0.0.1\8.2.0.0.1.32\bin folder. So I'm not understanding why I've mapped it to a certain directory but then it seems to take it to the next level and automatically put me in the last dir I was at. That's not the behavior I am looking for....<br/><br/><br/>net use z: \\servername.domain.com\share\8.2\8.2.0.0.1<br/>z:<br/>dir<br/>for /f "tokens=1-4* delims= " %%A in ( ' dir /tc /ad /<a href="https://interviewquestions.tuteehub.com/tag/od-583086" style="font-weight:bold;" target="_blank" title="Click to know more about OD">OD</a> ^| find "" ^| find /<a href="https://interviewquestions.tuteehub.com/tag/v-238055" style="font-weight:bold;" target="_blank" title="Click to know more about V">V</a> "" ' ) do if not "%%E"==".." if not "%%E"=="." set NewestFolder=%%E<br/>Echo Newest folder is "%NewestFolder%"<br/>cd %NewestFolder%<br/>e:<br/>chdir %HomeDir%<br/>net use z: /delete<br/>Windows remembers paths... <a href="https://interviewquestions.tuteehub.com/tag/thats-248329" style="font-weight:bold;" target="_blank" title="Click to know more about THATS">THATS</a> why I <a href="https://interviewquestions.tuteehub.com/tag/always-373607" style="font-weight:bold;" target="_blank" title="Click to know more about ALWAYS">ALWAYS</a> CD\. and have the batch refocus on the desired root start location and destination.</p></body></html>
8841.

Solve : Batch File for Find and replace multipal string in any file format?

Answer» <html><body><p>I want to create a batch file for finding and replacing a string in *.vb file.Why? Do you use VB?<br/>Can't that be done in VB?<br/>How to do the same in other file format <a href="https://interviewquestions.tuteehub.com/tag/like-537196" style="font-weight:bold;" target="_blank" title="Click to know more about LIKE">LIKE</a> .doc,.txt.exlFor a batch file, find and replace is limited to files that are some form of text format. Other formats have <a href="https://interviewquestions.tuteehub.com/tag/structures-17929" style="font-weight:bold;" target="_blank" title="Click to know more about STRUCTURES">STRUCTURES</a> that are not built for free replacement of text by another program.<br/><br/>A program such as MS word can accept a macro that <a href="https://interviewquestions.tuteehub.com/tag/opens-586856" style="font-weight:bold;" target="_blank" title="Click to know more about OPENS">OPENS</a> a file, <a href="https://interviewquestions.tuteehub.com/tag/replaces-622256" style="font-weight:bold;" target="_blank" title="Click to know more about REPLACES">REPLACES</a> text, saves the file and quits. The process can be started by a batch program or with some other agent.<br/>You may want to read this:<a href="https://support.microsoft.com/kb/210565"><br/>How to use startup command line switches to start Word</a><br/>Word is able to convert <a href="https://interviewquestions.tuteehub.com/tag/many-554478" style="font-weight:bold;" target="_blank" title="Click to know more about MANY">MANY</a> file formats.<br/>But not all kinds.</p></body></html>
8842.

Solve : Testing for & Enumerating %~* and %*?

Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a> All<br/>Finally joined the community after spending incalculable amounts of time combing through the site &amp; forums. Thanks to all for lending your expertise.<br/><br/>Although I create little 'batch' scripts regularly for deployments and various other <a href="https://interviewquestions.tuteehub.com/tag/tasks-25576" style="font-weight:bold;" target="_blank" title="Click to know more about TASKS">TASKS</a>, I often 'script' for fun. Today's one of those days. I'm writing a small .cmd file for my teammates to help them understand the various variables available at run time. Instead of writing out<br/>Code: <a>[Select]</a>echo %%~0 = %~0<br/>echo %%~1 = %~1<br/>echo %%~2 = %~2<br/>...<br/>echo %%~9 = %~9<br/><br/>rem testing arguments<br/>echo %%0 = %0<br/>echo %%1 = %1<br/>echo %%2 = %2<br/>...<br/>echo %%9 = %9<br/>I was hoping I could leverage <em>FOR /L</em> instead to do something like:<br/>Code: <a>[Select]</a>for /L %%a in (0,1,9) do (<br/> if defined %~%%a echo %%~%%a = %~%%a<br/> if defined %%a echo %%%a<br/>)<br/><br/>I don't know if I can, and how to, test whether or not %1 or %~1 have been defined via for loop.<br/><br/>Its silly, I know. Any ideas?Tricky, but I think Ive done it<br/>Code: <a>[Select]</a>@echo off<br/>echo %%* = %*<br/>for /L %%a in (0,1,9) do call :test %%a %%%%a<br/>goto :EOF<br/><br/>:test<br/>set p=<br/>call set p=%%2<br/>if "%p%"=="" goto :EOF<br/>echo %%%1 = %2<br/><br/>Anyone have any improvements ??<a href="https://interviewquestions.tuteehub.com/tag/nice-578299" style="font-weight:bold;" target="_blank" title="Click to know more about NICE">NICE</a> - very interesting results.<br/><br/>This seems to work well for testing arguments but not when enumerating %~* during run time. For instance...<br/><br/>I execute the following:<br/>Code: <a>[Select]</a>"C:\test\script.bat" "C:\test\script.bat" two three four five six seven eight nine<br/>Which returns:<br/>Code: <a>[Select]</a>%* = "C:\test\script.bat" two three four five six seven eight nine<br/>%0 = "C:\test\script.bat"<br/>%1 = "C:\test\script.bat"<br/>%2 = two<br/>%3 = three<br/>%<a href="https://interviewquestions.tuteehub.com/tag/4-238406" style="font-weight:bold;" target="_blank" title="Click to know more about 4">4</a> = four<br/>%5 = five<br/>%6 = six<br/>%7 = seven<br/>%8 = eight<br/>%9 = nine<br/>This works great for checking arguments and the like. However in situations where you might want to strip the quotes around the argument, you would have to use %~1, %~2 etc. Unfortunately there doesn't seem to be a way to do that. Dropping %~ in front of %2 fails altogether, and adding an extra % in front of that results in a literal output: %~two %~three etc.<br/><br/>The batch works as is but was just hoping to add some logic for argument checking. I was hoping I could do something like this but I can't get it to work properly even after <br/>Code: <a>[Select]</a>:EVALARGS<br/>if "%~0"=="" goto :NEXT<br/>echo %0<br/>shift<br/>goto :EVALARGS<br/><br/>According to <a href="http://www.robvanderwoude.com/if.php">http://www.robvanderwoude.com/if.php</a> I should be able to use the above example or even [%~0]==[] and "%~0"=="/?" but I had trouble there.Quote from: Phylum on May 25, 2011, 11:43:34 AM<blockquote>if "%~0"=="" goto :NEXT</blockquote><br/>But %0 is a special argument. and is unaffected by SHIFT, which dumps %1 and replaces it with %2 and so on until all non-null parameters are exhausted.<br/><br/>* You do know about ~d, ~p, ~n, ~x and the others?<br/><br/><br/>However...<br/><br/>Code: <a>[Select]</a>@echo off<br/>setlocal enabledelayedexpansion<br/>for /L %%a in (0,1,9) do (<br/> call set param=%%%%a<br/> if not "!param!"=="" (<br/> call echo %%%%%%a is %%%%a and %%%%~%%a is %%~%%a<br/> )<br/> )<br/><br/>Called with 5 parameters<br/><br/>Code: <a>[Select]</a>C:\Test&gt;nparams005.bat cat dog horse cheese "cake"<br/>%0 is nparams005.bat and %~0 is nparams005.bat<br/>%1 is cat and %~1 is cat<br/>%2 is dog and %~2 is dog<br/>%3 is horse and %~3 is horse<br/>%4 is cheese and %~4 is cheese<br/>%5 is "cake" and %~5 is cake<br/><br/>Hi Salmon Trout<br/><br/>I must have been out of my <a href="https://interviewquestions.tuteehub.com/tag/mind-1096965" style="font-weight:bold;" target="_blank" title="Click to know more about MIND">MIND</a> when I put %~0. As foolish as it looks now, I meant %~1 through 9. Thank you for that!<br/><br/>Your solution works perfectly! I struggled with trying to do what you did in the if statement, very creative!<br/><br/>In case anyone is ever curious about argument counting without using shift<br/>Code: <a>[Select]</a>set argcount=0<br/>for %%a in (%*) do Set /A argcount+=1</body></html>
8843.

Solve : Variable in FOR loop?

Answer» <html><body><p>Greetings. I am wanting to create a text file listing all the files in a <a href="https://interviewquestions.tuteehub.com/tag/directory-11615" style="font-weight:bold;" target="_blank" title="Click to know more about DIRECTORY">DIRECTORY</a>. A quick search on google provided myriad examples. The below for loop works fine. Note, I added the time stamp string in order to write the time stamp at the top of my file in my required format.<br/><br/>@ECHO OFF<br/>::Create timestamp as string<br/>SET Dt=%date:~10,4%%date:~4,2%%date:~7,2% %time%<br/>SET str=%dt%<br/>ECHO %str% &gt;&gt; c:\FileList.txt<br/>::The below FOR loop is an exact copy of an example I found on google.<br/>FOR /r "C:\Documents and Settings\Administrator\My Documents\My Pictures" %%X IN (*.jpg) DO (<br/>ECHO %%X &gt;&gt; c:\FileList.txt<br/>)<br/><br/>The above script works exactly as needed. My problem is that I want to introduce a variable within the FOR loop to hold the value of %%X. The reason is that I want to be able to manipulate it. The below is what I tried.<br/><br/>@ECHO OFF<br/>:: Create timestamp as string<br/>SETLOCAL ENABLEDELAYEDEXPANSION<br/>SET Dt=%date:~10,4%%date:~4,2%%date:~7,2% %time%<br/>SET str=%dt%<br/>ECHO %str% &gt;&gt; c:\FileList.txt<br/>FOR /r "C:\Documents and Settings\Administrator\My Documents\My Pictures" %%X IN (*.jpg) DO (<br/>SET !var! = %%X<br/>ECHO %var% &gt;&gt; c:\FileList.txt<br/>)<br/><br/>The output of the file looks like this:<br/>20110522 10:17:18.21 <br/>ECHO is off.<br/>ECHO is off.<br/>ECHO is off.<br/>ECHO is off.<br/>.....<br/><br/>I read a little bit about the SETLOCAL ENABLEDELAYEDEXPANSION option, but I'm not sure that I fully get it, as my limited experience is with VB. What I want to do is ECHO %var% instead of %%X, once again, because I want to be able to further manipulate it once I can get it working. I should also note I am not experienced with DOS code (or what ever it is called). I would greatly appreciate any suggestions or help. Thank you.<br/><br/>Greg<br/><br/>You need to focus on this area. Make a test batch with just this part of your work. By braking something into smaller parts, it is easier to see what happens.<br/><br/>Quote</p><blockquote>FOR /r "C:\Documents and Settings\Administrator\My Documents\My Pictures" %%X IN (*.jpg) DO (<br/> SET !var! = %%X<br/> ECHO %var% &gt;&gt; c:\FileList.txt <br/> )</blockquote><br/>Try to debug your test batch with more ECHO statements. For example, use a simple ECHO of the variable befog and after you change it. Surprise! Delayed expansion ?<br/>A very "interesting" post from Geek.<br/><br/>gsnidow, due to the way the Windows NT family command interpreter (which is not "DOS", by the way) processes variable expansion in FOR structures, to set and expand variables within a loop, you need to use "delayed expansion". You set it up in a batch file by including this line somewhere before the loop<br/><br/>setlocal enabledelayedexpansion<br/><br/>The case doesn't matter - upper or lower or a mixture of the two, all are OK. Mostly it's OK to put it right at the start after the @echo off line that starts most scripts. If you leave it out then you can't use delayed expansion variables of the !var! type<br/><br/>Now, we come to how you use this feature within a loop, (in fact within any structure where multiple lines are enclosed in brackets)<br/><br/>You assign (set) the variable in the normal way, by using the set command followed immediately by an equals sign and then the variable value:<br/><br/><strong>SET var=%%X</strong><br/><br/>Note that there are <em>no</em> exclamation marks ("exclamation points") in the above line.<br/><br/>To read (expand) the variable within the loop you treat it like a normal variable, but with the difference that you use exclamation marks (!) and not percent signs (%):<br/><br/><strong>echo !var! &gt;&gt; c:\FileList.txt</strong><br/><br/>You can do all the usual variable processing stuff with such a variable.<br/><br/>Note also that once the loop has finished (after the closing bracket of the loop) you can still access the variable but you use percent signs as normal. In the script you showed above, after the loop has finished, %var% will contain the last value that !var! held. This might be useful sometimes if you want to know the last item in a list or sequence.<br/><br/>A point - using double colons :: as comment markers is unofficial, undocumented and unsupported, and will in certain situations (within a loop for example) break a script. Use REM or Rem or rem or ReM instead.<br/><br/>Another point - writing ALL the commands in UPPER CASE is not compulsory.<br/><br/><br/><br/><br/><br/>Thank you so much Geek and Salmon for the very helpful points. I have made it easier on myself by creating c:\test, and putting only 3 files in it, Test1.txt..Test3.txt. At Geek's suggestion, I have been working on only the problem part, which, with my new test folder, boils down to...<br/><br/>FOR /r "C:\test" %X IN (*.txt) DO SET var = %X<br/><br/>Note I am not trying to do this in a batch file now, because I want to see what is happening in the cmd window. As expected, the output of this line is...<br/><br/>C:\...&gt;SET var = C:\test\Test1.txt<br/>C:\...&gt;SET var = C:\test\Test2.txt<br/>C:\...&gt;SET var = C:\test\Test3.txt<br/><br/>This <a href="https://interviewquestions.tuteehub.com/tag/result-238022" style="font-weight:bold;" target="_blank" title="Click to know more about RESULT">RESULT</a> seems to me to imply that for each iteration of the loop, it is correctly assigning the value of the current file name to the var variable. I then tried this...<br/><br/>FOR /r "C:\test" %X IN (*.txt) DO SET var = %X ECHO %var<br/><br/>My thought was that since, based on my assumption above, the variable is being correctly set, the next step would be to ECHO it. However, this is not the case, as the output is now...<br/><br/>C:\...&gt;SET var = C:\test\Test1.txt ECHO %var<br/>C:\...&gt;SET var = C:\test\Test2.txt ECHO %var<br/>C:\...&gt;SET var = C:\test\Test3.txt ECHO %var<br/><br/>It seems that it is only appending "ECHO %var" to the variable value, along with the file name of the current iteration. I am thinking it must be possible to carry out multiple actions in the DO part of the loop, but I can't seem to get it. One question to the delayed execution: I am having trouble understanding why it is necessary if, based on my first results, it seems to be correctly assigning the variable value without it.<br/><br/>@Salmon - I'm going to continue to mess with it before I simply copy and paste your line of code, so I will probably have some more questions later. As for the all caps, I'm a <a href="https://interviewquestions.tuteehub.com/tag/sql-4621" style="font-weight:bold;" target="_blank" title="Click to know more about SQL">SQL</a> guy, and my practice is to always put key words in all caps, because it makes the code easier to read.<br/><br/>Once again, I very much appreciate both of your helping me as I muddle through being a newbie at this. Thank you so much.<br/><br/>Greg<br/><br/><br/><br/><br/><br/>Quote<blockquote>FOR /r "C:\test" %X IN (*.txt) DO SET var = %X ECHO %var</blockquote><br/>1. You can't do this.<br/><br/>2. Variables have a percent sign before and after so %var won't work.<br/><br/>3. <br/><br/>Quote<blockquote> As expected, the output of this line is...<br/><br/>C:\...&gt;SET var = C:\test\Test1.txt<br/>C:\...&gt;SET var = C:\test\Test2.txt<br/>C:\...&gt;SET var = C:\test\Test3.txt<br/></blockquote><br/>It was just echoing "set var = " (which is wrong; lose those spaces) and expanding %X. The variable %var% was not being set correctly. Trust me.<br/><br/>Quote<blockquote>It was just echoing "set var = " (which is wrong; lose those spaces) and expanding %X. The variable %var% was not being set correctly. Trust me.</blockquote><br/>Ah ha, those darned spaces. All seems to be good now, so I very much appreciate the help. One last question, how do I know when to use '%' and when to use '!' to wrap my variables? Thanks again.<br/><br/>GregQuote from: gsnidow on May 23, 2011, 05:51:16 AM<blockquote>how do I know when to use '%' and when to use '!' to wrap my variables? Thanks again.</blockquote><br/>You use % all the time except when you want to expand a variable, in a loop or other parenthetical structure (e.g. a long form IF), which you have previously set in that structure.<br/><br/><br/>@Salmon - I apologize if this is a newbie question, but I don't know what you mean by expanding a variable. I read some stuff on google, but most of it was dealing with posters having issues with expanding their variables in various languages. Could you possibly put it in laymen terms? Thanks.<br/><br/>GregWhole waiting or Salmon Trout, here is some more reading.<br/><a href="http://www.robvanderwoude.com/variableexpansion.php">http://www.robvanderwoude.com/variableexpansion.php</a>Quote from: gsnidow on May 23, 2011, 08:14:40 PM<blockquote>I don't know what you mean by expanding a variable. Could you possibly put it in laymen terms?</blockquote><br/><br/>OK here <a href="https://interviewquestions.tuteehub.com/tag/goes-1732621" style="font-weight:bold;" target="_blank" title="Click to know more about GOES">GOES</a>...<br/><br/>You create a variable with the SET command, and when you use it in a statement, it gets "expanded" by the command interpreter cmd.exe.<br/><br/>set animal=cat<br/><br/>The command interpreter reserves some memory space for a variable called "animal" and stores the <a href="https://interviewquestions.tuteehub.com/tag/three-708969" style="font-weight:bold;" target="_blank" title="Click to know more about THREE">THREE</a> characters 'cat' in that space.<br/><br/>later you have<br/><br/>echo %animal%<br/><br/>When the command interpreter processes this line it identifies the variable because of the percent signs and looks up the value of "animal" in its list of variables. It finds 'cat' so it replaces %animal% with cat and executes <br/><br/>echo cat<br/><br/>This process of replacing a variable's name with the value it holds is called "expansion".<br/><br/><br/><br/><br/>Thanks for the help and explanation guys. That is a great article, and it does not seem so strange now. I very much appreciate you taking time out of your busy days to consider and respond to my questions. <br/><br/>Greg</body></html>
8844.

Solve : read next line of source file?

Answer» <html><body><p>I need help to create a set of subdirectories two levels down in a root directory. I have to use a source file to read from but do not know how to get the next line of the source file.<br/><br/>The root directory has the following structure:<br/>e:\26334\7327\<br/>e:\26335\7317\<br/>e:\26910\7690\<br/>e:\26912\7100\<br/>e:\26916\1414\<br/>e:\27127\7702\<br/>e:\28145\4726\<br/>e:\28177\4122\<br/>e:\28189\7125\<br/>e:\28211\3527\<br/>e:\28528\8236\<br/>e:\28535\8155\<br/>e:\28746\6291\<br/>e:\29036\3448\<br/>e:\29222\8231\<br/>and so on...<br/><br/>I am using a source file to read from that looks like this:<br/>23742\3524<br/>26035\8919<br/>26316\7814<br/>26334\1223<br/>26334\7327<br/>26910\7690<br/>27127\7702<br/>28145\4726<br/>28211\3527<br/>28528\8236<br/>28535\8155<br/>28746\6291<br/>29036\3448<br/>29222\8231<br/>29353\1669<br/>30529\4689<br/>30843\7460<br/>31415\8053<br/>and so on...<br/><br/>The source file is called dir-list.txt. The batch file I'm trying to create will be run from the root e:\<br/><br/>The following is the batch file so far:<br/><br/>::---<br/>FOR /F "tokens=1 eol=^" %%G IN (dir-list.txt) DO (<br/><br/>::combine current directory with path returned in variable %%G<br/>set "<a href="https://interviewquestions.tuteehub.com/tag/d1-943172" style="font-weight:bold;" target="_blank" title="Click to know more about D1">D1</a>=%cd%"<br/>set "D2=%%G"<br/>set "DD=%D1%\%D2%"<br/><br/>::find destination directory<br/>IF EXIST %DD% GOTO cd<br/><br/>::change directory to destination directory<br/>:cd<br/>PUSHD %DD%<br/>GOTO md<br/><br/>::create folders in destination directory<br/>:md<br/>MD TEST1, TEST2, TEST3<br/><br/>::return to <a href="https://interviewquestions.tuteehub.com/tag/original-1139424" style="font-weight:bold;" target="_blank" title="Click to know more about ORIGINAL">ORIGINAL</a> directory<br/>POPD<br/>)<br/>::---<br/><br/>This works by creating the folders TEST1, TEST2 and TEST3 under the second level down but then stops after one iteration. I need it to go through the dir-list.txt until the end. Also, I don't have any error routine for the folders that are not in the dir-list.txt or the entries in the dir-list.txt that are not found in the root directory. The root directory is on a Windows 2008 r2 machine. Thank you for any suggestions.1. You need to use delayed expansion to set and use variables in a FOR loop. Use Google to find out about this.<br/>2. Do not start comment lines with unofficial, unsupported, deplored, BAD double colons. ( This breaks FOR loops. Use the proper <a href="https://interviewquestions.tuteehub.com/tag/rem-613824" style="font-weight:bold;" target="_blank" title="Click to know more about REM">REM</a> instead.<br/><br/>Then see if your code works. <br/><br/>Thanks for the reply.<br/>I tried it with the setlocal enabledelayedexpansion.<br/>the following is the output of the batch file. I removed the comments.<br/>E:\&gt;test.bat<br/><br/>E:\&gt;SETLOCAL enabledelayedexpansion<br/><br/>E:\&gt;FOR /F "tokens=1 eol=^" %G IN (dir-list.txt) DO (<br/>set "D1=E:\"<br/>set "D2=%G"<br/>set "DD=E:\01333\8915"<br/>IF EXIST E:\01333\8915 GOTO cd<br/>PUSHD E:\01333\8915<br/>GOTO md<br/>MD TEST1, TEST2, TEST3<br/>POPD<br/>)<br/><br/>E:\&gt;(<br/>set "D1=E:\"<br/>set "D2=01333\8915"<br/>set "DD=E:\01333\8915"<br/>IF EXIST E:\01333\8915 GOTO cd<br/>PUSHD E:\01333\8915<br/>GOTO md<br/>MD TEST1, TEST2, TEST3<br/>POPD<br/>)<br/><br/>E:\&gt;PUSHD E:\TEMP\01333\8915<br/><br/>E:\01333\8915&gt;GOTO md<br/><br/>E:\01333\8915&gt;MD TEST1, TEST2, TEST3<br/><br/>E:\01333\8915&gt;POPD<br/>E:\&gt;<br/>--------------------------------------------<br/><br/>It still stops after one iteration. You showed the output but not the new code. Why? Also, why do you have gotos and labels inside a loop? (That's why you can't have double colon "comments" inside a loop, because such a comment is really a broken label, and labels break loops.) Did you actually "write" this code yourself, or did you just copy and paste bits of other batch scripts you found on the web? It would be better if you went back to the beginning and started again, studying batch script syntax carefully.<br/>As I indicated in my post, I removed the comments and added the SETLOCAL enabledelayedexpansion, so didn't think the code was needed because beyond that, the code was the same. And yes, I wrote it all by my lonesome. I subsequently <a href="https://interviewquestions.tuteehub.com/tag/moved-2846161" style="font-weight:bold;" target="_blank" title="Click to know more about MOVED">MOVED</a> the goto out of the loop and it continues through the entire source file. But then I had trouble reinitializing the %DD% variable. It kept the same value through all iterations. So, to keep from further disrupting this great forum, I accomplished it in about 1/2 an hour in C#. <a href="https://interviewquestions.tuteehub.com/tag/sorry-648642" style="font-weight:bold;" target="_blank" title="Click to know more about SORRY">SORRY</a>, I create batch files all the time for simpler stuff and thought it would have been easy. Swim on Mister Trout! Thanks for the help.This code needs work but should help get you started. I will write more latter. Good luck<br/><br/>@echo off<br/>setlocal enabledelayedexpansion<br/>FOR /F %%i in (dir-list.txt) do (<br/><br/>rem combine current directory with path returned in variable %%i<br/>set D1=%%i<br/>echo D1=!D1!<br/>set D2=%%i<br/>echo D2=!D2!<br/>set DD=!D1!/!D2!<br/>echo DD=!DD!<br/>echo.<br/>)<br/>pause<br/>rem find destination directory<br/>IF EXIST !DD! goto chgdir<br/><br/>rem change directory to destination directory<br/>:chgdir<br/>echo DD=!DD!<br/>echo pushd<br/>popd<br/>PUSHD<br/><br/><br/>echo DD=!DD!<br/>pause<br/>popd<br/>dir<br/>pause<br/><br/><br/>rem create folders in destination directory<br/><br/>rd xTEST1, xTEST2, xTEST3<br/><br/>md xTEST1, xTEST2, xTEST3<br/><br/>rem return to original directory<br/>POPD<br/>echo DD=!DD!<br/>)<br/><br/><br/>C:\test&gt;<br/><br/><br/>C:\test&gt; lexus.bat<br/>D1=23742\3524<br/>D2=23742\3524<br/>DD=23742\3524/23742\3524<br/><br/>D1=26035\8919<br/>D2=26035\8919<br/>DD=26035\8919/26035\8919<br/><br/>D1=26316\7814<br/>D2=26316\7814<br/>DD=26316\7814/26316\7814<br/><br/>D1=26334\1223<br/>D2=26334\1223<br/>DD=26334\1223/26334\1223<br/><br/>D1=26334\7327<br/>D2=26334\7327<br/>DD=26334\7327/26334\7327<br/><br/>D1=26910\7690<br/>D2=26910\7690<br/>DD=26910\7690/26910\7690<br/><br/>D1=27127\7702<br/>D2=27127\7702<br/>DD=27127\7702/27127\7702<br/><br/>D1=28145\4726<br/>D2=28145\4726<br/>DD=28145\4726/28145\4726<br/><br/>D1=28211\3527<br/>D2=28211\3527<br/>DD=28211\3527/28211\3527<br/><br/>D1=28528\8236<br/>D2=28528\8236<br/>DD=28528\8236/28528\8236<br/><br/>D1=28535\8155<br/>D2=28535\8155<br/>DD=28535\8155/28535\8155<br/><br/>D1=28746\6291<br/>D2=28746\6291<br/>DD=28746\6291/28746\6291<br/><br/>D1=29036\3448<br/>D2=29036\3448<br/>DD=29036\3448/29036\3448<br/><br/>D1=29222\8231<br/>D2=29222\8231<br/>DD=29222\8231/29222\8231<br/><br/>D1=29353\1669<br/>D2=29353\1669<br/>DD=29353\1669/29353\1669<br/><br/>D1=30529\4689<br/>D2=30529\4689<br/>DD=30529\4689/30529\4689<br/><br/>D1=30843\7460<br/>D2=30843\7460<br/>DD=30843\7460/30843\7460<br/><br/>D1=31415\8053<br/>D2=31415\8053<br/>DD=31415\8053/31415\8053<br/><br/>Press any key to continue . . .</p></body></html>
8845.

Solve : Need MS-DOS Latest version Download info?

Answer» <html><body><a href="https://interviewquestions.tuteehub.com/tag/hi-479908" style="font-weight:bold;" target="_blank" title="Click to know more about HI">HI</a>,<br/><br/>where can i find the source (MS-DOS <a href="https://interviewquestions.tuteehub.com/tag/file-11330" style="font-weight:bold;" target="_blank" title="Click to know more about FILE">FILE</a>) to <a href="https://interviewquestions.tuteehub.com/tag/upgrade-1440168" style="font-weight:bold;" target="_blank" title="Click to know more about UPGRADE">UPGRADE</a> the <a href="https://interviewquestions.tuteehub.com/tag/existing-979526" style="font-weight:bold;" target="_blank" title="Click to know more about EXISTING">EXISTING</a> one?<br/><br/>Thanks, <br/>SravanMS-DOS is a copyrighted <a href="https://interviewquestions.tuteehub.com/tag/product-25523" style="font-weight:bold;" target="_blank" title="Click to know more about PRODUCT">PRODUCT</a>. <br/>You have to buy it.<br/>Quote<blockquote>Microsoft MS-DOS 6 Upgrade Operating System<br/>by Microsoft <br/>Price: $26.99<br/>ttp://www.amazon.com</blockquote>Upgrade to version 6.22 from any earlier version 6.xx free from Microsoft<br/><br/><a href="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=96cc3197-b7e5-4b31-badb-ddaac771295f">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=96cc3197-b7e5-4b31-badb-ddaac771295f</a></body></html>
8846.

Solve : Old Computer with bad hard drive - need help with autoexec.bat?

Answer» <html><body><p>I have an old laptop with a bad hard drive. The laptop is an CTX Ezbook 700.<br/>I was able to correctly install <a href="https://interviewquestions.tuteehub.com/tag/everything-25538" style="font-weight:bold;" target="_blank" title="Click to know more about EVERYTHING">EVERYTHING</a> - except the CD Rom Drive.<br/><br/>It is working in DOS 5. I made changes to the <a href="https://interviewquestions.tuteehub.com/tag/setup-1203067" style="font-weight:bold;" target="_blank" title="Click to know more about SETUP">SETUP</a>, created a new config.sys and Autoexec.bat. When it starts now, there are no obvious errors it Setup, the config.sys has no obvious errors. The autoexec tells me I have successfully <br/>installed Drive C: (even though I specified drive d: in the autoexec file.). <br/><br/>When I check further, d: does not <a href="https://interviewquestions.tuteehub.com/tag/work-20377" style="font-weight:bold;" target="_blank" title="Click to know more about WORK">WORK</a> c: does not produce an error<br/>c: is there logically - but there is no actual c: drive so I cant't use that either.<br/><br/>Is the Problem in Setup or in the autoexec.bat or did I miss something in the Config.sys file.<br/><br/>I tried putting in a <a href="https://interviewquestions.tuteehub.com/tag/linux-1946" style="font-weight:bold;" target="_blank" title="Click to know more about LINUX">LINUX</a> disk in the cd drive - but that didn't work either<br/>t<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>Quote</p><blockquote>The autoexec tells me I have successfully<br/>installed Drive C: (even though I specified drive d: in the autoexec file.). <br/></blockquote><br/>It <a href="https://interviewquestions.tuteehub.com/tag/sounds-1219274" style="font-weight:bold;" target="_blank" title="Click to know more about SOUNDS">SOUNDS</a> like you are booting from a floppy? In which case A: and B: are reserved for floppy drives, then C will be the system (MS-DOS) drive if present, and if not that letter will get assigned to the CD-ROM. The autoexec massage must be from MSCDEX.<br/><br/><br/>Massage..... <br/><br/>Post the config.sys and autoexec.bat files for review...</body></html>
8847.

Solve : Taking the spaces out of file names in a batch of files?

Answer» <html><body><p>Hi folks,<br/><br/>I'm just a beginner here with MS-Dos, but recently I've learned some neat <a href="https://interviewquestions.tuteehub.com/tag/ways-25480" style="font-weight:bold;" target="_blank" title="Click to know more about WAYS">WAYS</a> of doing things through CMD that have saved me quite some time. <a href="https://interviewquestions.tuteehub.com/tag/one-241053" style="font-weight:bold;" target="_blank" title="Click to know more about ONE">ONE</a> example is a large file file rename. My job requires me to rename image files for products according to theire UPC. By using a the ren or rename function and some vlookup in excel I am able to rename a bunch of files by simply doing a directory dump and <a href="https://interviewquestions.tuteehub.com/tag/copying-426077" style="font-weight:bold;" target="_blank" title="Click to know more about COPYING">COPYING</a> that into excel. I then match those file names (who usually have model numbers) up to the corresponding UPCs. I then <a href="https://interviewquestions.tuteehub.com/tag/run-1192138" style="font-weight:bold;" target="_blank" title="Click to know more about RUN">RUN</a> a copy and paste formula in excel that read something like this ="ren "&amp;A39&amp;" "&amp;c39&amp;".jpg" and copy that formula into all my cells. Now I have text in each cell that reads something like this ren W0102 COFFRET ACCESSOIRES.jpg 746775023492.jpg I then proceed to copy all my the column with all the rename formulas in text and paste it in CMD and voila, all my file are renamed. <strong>Now for my question, can I do something similar to what I have just described to take the spaces out of my file names?</strong> This would be helpful as when my original file has space I have to go through and take them out as if they were there my rename formula would not work. <strong><strong>My files would be located in C:\Users\Eddie\Desktop\Images <strong>So is there anyway I can go into a directory and take the spaces out of each file name with a DOS script or <a href="https://interviewquestions.tuteehub.com/tag/command-11508" style="font-weight:bold;" target="_blank" title="Click to know more about COMMAND">COMMAND</a>?</strong></strong></strong> <em>Thank you for reading through that meaty bit of writing!</em>Run the script and if you are happy with how it works remove 'echo' from the start of the 7th line.<br/><br/>Code: <a>[Select]</a>@echo off<br/>setlocal enabledelayedexpansion<br/>cd /d "C:\Users\Eddie\Desktop\Images"<br/>for /f "delims=" %%A in ('dir /b *.jpg') do (<br/> set oldfilename=%%A<br/> set newfilename=!oldfilename: =!<br/> echo ren "!oldfilename!" "!newfilename!"<br/> )<br/>echo. <br/>echo all done<br/>pause</p></body></html>
8848.

Solve : Display only total files and bytes line on dir command?

Answer» <html><body><p>I am creating a batch file to backup certain directories. After the copy command, I want to compare the total files and bytes of the original directory to the backup directory to confirm everything worked ok. I have used the dir /s command, but that displays pages of files and folders, making the comparison on one screen impossible. What I want to do is display only the next to last line that shows the total files and bytes. <br/><br/>I have tried the dir /s c:\xxxxxx | FIND "File(s)", which works, however it also displays the total files/bytes for each of the folders, resulting in pages of results. I only want the final grand total of the entire directory. If there were something unique in the "string" for that line, I would be <a href="https://interviewquestions.tuteehub.com/tag/fine-248571" style="font-weight:bold;" target="_blank" title="Click to know more about FINE">FINE</a>, however the lines are the same, except that the sub-directories show "<a href="https://interviewquestions.tuteehub.com/tag/0-242464" style="font-weight:bold;" target="_blank" title="Click to know more about 0">0</a> Files", where the grand total line shows shows a number instead of "0". <br/><br/>Does anyone know how to display only the grand total line and not each separate folder total line?<br/><br/>Thanks,<br/>Quote</p><blockquote>If there were something unique in the "string" for that line, I would be fine</blockquote><br/>There is something unique - its position in the output listing, so we can use a FOR loop to successively assign the line <a href="https://interviewquestions.tuteehub.com/tag/containing-2035611" style="font-weight:bold;" target="_blank" title="Click to know more about CONTAINING">CONTAINING</a> "File(s)" to a variable and when the loop is over the variable holds the final value. Just like dir /s, the code below will appear to do nothing for a while if the tree is a deep one with many files.<br/><br/>Code: <a>[Select]</a>@echo off<br/>for /f "delims=" %%A in ( ' dir /s "D:\Folder" ^| find "File(s)" ' ) do set total=%%A<br/>Echo Total for tree is %total%<br/>Developed a bit...<br/><br/>Code: <a>[Select]</a>@echo off<br/>set folder1="D:\test"<br/>set folder2="T:\test"<br/>for /f "delims=" %%A in ( ' dir /s %folder1% ^| find "File(s)" ' ) do set total1=%%A<br/>for /f "delims=" %%A in ( ' dir /s %folder2% ^| find "File(s)" ' ) do set total2=%%A<br/>for /F "tokens=1-4" %%A in ("%total1%") do (<br/> set files1=%%A<br/> set bytes1=%%C<br/> )<br/>for /F "tokens=1-4" %%A in ("%total2%") do (<br/> set files2=%%A<br/> set bytes2=%%C<br/> )<br/>Echo Folder: %folder1% Files: %files1% Bytes: %bytes1%<br/>Echo Folder: %folder2% Files: %files2% Bytes: %bytes2%<br/>if "%files1%"=="%files2%" (<br/> echo Number of files: identical<br/>) else (<br/> echo Number of files: NOT identical<br/>)<br/>if "%bytes1%"=="%bytes2%" (<br/> echo <a href="https://interviewquestions.tuteehub.com/tag/size-246425" style="font-weight:bold;" target="_blank" title="Click to know more about SIZE">SIZE</a> of data: identical<br/>) else (<br/> echo Size of data: NOT identical<br/>)<br/><br/>Code: <a>[Select]</a>Folder: "D:\test" Files: 2043 Bytes: 165,993,132<br/>Folder: "T:\test" Files: 2043 Bytes: 165,993,132<br/>Number of files: identical<br/>Size of data: identical</body></html>
8849.

Solve : Detect and Eject Removable Disk in cmd?

Answer» <html><body><p>hi<br/>how can i create the batch file to detect and eject removable drive automatically ?<br/>tnxsomething like this? <br/><a href="http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133">http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133</a>tnx for reply,<br/>but i want to detect usb mass drive and eject it. (something like safe <a href="https://interviewquestions.tuteehub.com/tag/remove-1184766" style="font-weight:bold;" target="_blank" title="Click to know more about REMOVE">REMOVE</a>!) Quote from: rockhudson on July 28, <a href="https://interviewquestions.tuteehub.com/tag/2011-290379" style="font-weight:bold;" target="_blank" title="Click to know more about 2011">2011</a>, 10:36:39 AM</p><blockquote>Wlll not eject automatically. USB stick is safe to remove manually at any time.<br/></blockquote><br/>That advice is reckless. Delayed write and programs that have a file open on the device will not take too kindly to your yanking the device from the port.<br/><br/>Could not find a script to do a safe remove but you can enter this command in a batch file which will present the GUI:<br/><br/>Code: <a>[Select]</a>RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll<br/><br/>There are also third <a href="https://interviewquestions.tuteehub.com/tag/party-596714" style="font-weight:bold;" target="_blank" title="Click to know more about PARTY">PARTY</a> programs which claim to <a href="https://interviewquestions.tuteehub.com/tag/accomplish-846960" style="font-weight:bold;" target="_blank" title="Click to know more about ACCOMPLISH">ACCOMPLISH</a> this. Google will be helpful here.<br/><br/>Good luck. <br/><br/>BTW: Didn't Rock Hudson die some years ago. Good to see the cemetery crowd on CH.Quote<blockquote>Wlll not eject automatically. USB stick is safe to remove manually at any time.</blockquote><br/>Agreed ...shifty advice at best.Quote from: behad-007 on July 27, 2011, 02:44:33 AM<blockquote>Tnx for reply,<br/>but i want to detect usb mass drive and eject it. (something like safe remove!)<br/></blockquote><br/>Transfusion wrote:<br/>"Something like this? <br/><a href="http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133">http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133</a>"<br/><br/>The Transfusion method Is for a CD drive with a door. The OP,behad-007, is concerned with a USB storage device.<br/><br/>_______________________________________ ______<br/><br/>There is safely remove USB icon at the lower right.<br/><br/>Remove USB drive when Safely Remove Hardware icon <a href="https://interviewquestions.tuteehub.com/tag/appears-881937" style="font-weight:bold;" target="_blank" title="Click to know more about APPEARS">APPEARS</a> at the lower right.Quote from: Fred35 on July 28, 2011, 05:46:31 PM<blockquote>Transfusion wrote:<br/>"Something like this? <br/><a href="http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133">http://www.911cd.net/forums//index.php?s=924b5513860a93a2c9bef812b0718a05&amp;showtopic=13917&amp;pid=132133&amp;st=0&amp;#entry132133</a>"<br/><br/>The Transfusion method Is for a CD drive with a door. The OP,behad-007, is concerned with a USB storage device.<br/><br/>_______________________________________ ______<br/><br/>There is safely remove USB icon at the lower right.<br/><br/>Remove USB drive when Safely Remove Hardware icon appears at the lower right.<br/></blockquote><br/>_______________________________________ _____<br/>When icon does not appear do:<br/><br/>RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll<br/><br/><a href="http://ask-leo.com/safely_remove_hardware_where_did_the_icon_go_how_do_i_safely_remove_hardware_without_it.html">http://ask-leo.com/safely_remove_hardware_where_did_the_icon_go_how_do_i_safely_remove_hardware_without_it.html</a>thanks to all for reply,<br/>this code was very helpful <br/><br/>RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll</body></html>
8850.

Solve : Exclamation Marks [!] in DOS text files cause 'FOR /F' processing problems.?

Answer» <html><body><p>I'm using 'FOR /F' to change every occurrence of 'X' to 'Y' in every line of a text file.<br/><br/>So far so good, but problems occur if the text file contains exclamation marks [!]. Exclamation marks, and any text between them are lost.<br/><br/>My input file [Test-myfile.txt] contains...<br/><br/>Line 01 containing A but not X!<br/>Line 02 containing A but not X!Watch this space!X<br/>Line 03 containing X but not Y! and another xylophone.<br/>Line 04 containing X and Y and another x and a word like axiom.<br/>Line 05 containing Y but not X;<br/>Line 06 containing Xxx but not Yyy:<br/>Line 07 containing B and Z and Y~<br/>Line 08 containing Y but not X#<br/>Line 09 containing X and Y and another xylophone<br/><br/>My MS-DOS batch code [Test_Change_CharactersInStrings_110508.bat] is as follows...<br/><br/>@ECHO OFF<br/>COLOR F5<br/><br/>REM====================================================<br/>REMCode to change every occurrence of 'X' to 'Y' --<br/>REMin every line of 'Test-myfile.txt'...<br/>REM====================================================<br/>REMNeed to check why exclamation marks [!], and any text between them are lost???<br/>REM====================================================<br/><br/>@ECHO OFF &gt; newfile.txt<br/>SETLOCAL EnableDelayedExpansion<br/>FOR /F "tokens=1,2,3,4,5,6,7-15* delims= " %%a in (Test-myfile.txt) DO (<br/>REMPAUSE<br/>ECHO a[%%a]<br/>REMPAUSE<br/>ECHO b[%%b]<br/>ECHO c[%%c]<br/>ECHO d[%%d]<br/>ECHO e[%%e]<br/>ECHO f[%%f]<br/>ECHO g[%%g]<br/>ECHO h[%%h]<br/>ECHO i[%%i]<br/>ECHO j[%%j]<br/>ECHO k[%%k]<br/>ECHO l[%%l]<br/>ECHO m[%%m]<br/>ECHO n[%%n]<br/>ECHO o[%%o]<br/>REMSET LINE_TEXT=%%a<br/>SET LINE_TEXT=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o<br/>ECHO Original line...!LINE_TEXT!<br/>SET LINE_TEXT=!LINE_TEXT:X=Y!<br/>ECHO Modified line...!LINE_TEXT!<br/>ECHO !LINE_TEXT! &gt;&gt; newfile.txt<br/>)<br/>ECHO Done!<br/>SETLOCAL DisableDelayedExpansion<br/>ECHO Last modified line...%LINE_TEXT%<br/>PAUSE<br/>EXIT<br/><br/>After running the code, my output file [newfile.txt] contains...<br/><br/>Line 01 containing A but not Y <br/>Line 02 containing A but not YY <br/>Line 03 containing Y but not Y and another Yylophone. <br/>Line 04 containing Y and Y and another Y and a word like aYiom. <br/>Line 05 containing Y but not Y; <br/>Line 06 containing YYY but not Yyy: <br/>Line 07 containing B and Z and Y~ <br/>Line 08 containing Y but not Y# <br/>Line 09 containing Y and Y and another Yylophone <br/><br/>Any ideas of how I can prevent exclamation marks, and any text between them, from being lost?<br/>The string variable for each line is not being created correctly because with delayed expansion enabled, exclamation marks are variable delimiters and thus are ignored along with everything between them. Batch scripts get terribly fiddly when special characters ("poison characters" are embedded in strings to be processed. The worst is the ampersand but parentheses and percent signs are among the others.<br/><br/>What I did below is to take the set of tokens spat out by FOR /F and create a string enclosed in quotes so I could pass it as one single parameter to a CALLed subroutine where the tilde variable modifier strips off the quotes and then the X=Y substitution takes place, followed by the output to the file. No delayed expansion needed.<br/><br/>Consider "<a href="https://interviewquestions.tuteehub.com/tag/call-412416" style="font-weight:bold;" target="_blank" title="Click to know more about CALL">CALL</a> :replace" to be equivalent to "GOSUB replace" in BASIC, and "GOTO :eof" to be equivalent to "RETURN" in BASIC. The colons are obligatory, not optional like they are when using GOTO with labels.<br/><br/>batch script<br/>Code: <a>[Select]</a>@ECHO OFF<br/>REM ====================================================<br/>REM Code to change every occurrence of 'X' to 'Y' --<br/>REM in every line of 'Test-myfile.txt'...<br/>REM ====================================================<br/>@ECHO OFF &gt; newfile.txt<br/>FOR /F "tokens=1,2,3,4,5,6,7-15* delims= " %%a in (Test-myfile.txt) DO (<br/> call :replace "%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o"<br/> )<br/>ECHO Done!<br/>pause<br/>exit<br/> <br/>:replace<br/>set string1=%~1<br/>set string2=%string1:X=Y%<br/>echo %string2% &gt;&gt; newfile.txt<br/>goto :eof<br/><br/>newfile.txt<br/>Code: <a>[Select]</a>Line 01 containing A but not Y! <br/>Line 02 containing A but not Y!Watch this space!Y <br/>Line 03 containing Y but not Y! and another Yylophone. <br/>Line 04 containing Y and Y and another Y and a word like aYiom. <br/>Line 05 containing Y but not Y; <br/>Line 06 containing YYY but not Yyy: <br/>Line 07 containing B and Z and Y~ <br/>Line 08 containing Y but not Y# <br/>Line 09 containing Y and Y and another Yylophone <br/>ST, thank you very much for providing a solution to my problem -- I had unsuccessfully searched several websites looking for information on it before you came up with the goods.<br/><br/>One further point about my example is that I notice that the character substitution changes 'X' or 'x' (upper and lower case) to 'Y' (the resulting character is the case as specified). Is there a way to preserve the original case of the target character? (i.e. 'X' becomes 'Y', and 'x' becomes 'y'). Thanks in anticipation.<br/><br/>Incidently, ST, I tried to thank you by clicking the 'Thank Salmon Trout' button but <a href="https://interviewquestions.tuteehub.com/tag/got-23540" style="font-weight:bold;" target="_blank" title="Click to know more about GOT">GOT</a>...<br/><br/>"An Error Has Occurred! Sorry, you can't repeat a karma action without waiting 2 hours."<br/><br/>Don't know what that's all about!<br/>Give this a try<br/><br/>Code: <a>[Select]</a>@ECHO OFF<br/>REM ====================================================<br/>REM Code to change every occurrence of 'X' to 'Y' --<br/>REM in every line of 'Test-myfile.txt'...<br/>REM ====================================================<br/>@ECHO OFF &gt; newfile.txt<br/>FOR /F "tokens=1,2,3,4,5,6,7-15* delims= " %%a in (Test-myfile.txt) DO (<br/> call :replace "%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o"<br/> )<br/>ECHO Done!<br/>pause<br/>exit<br/> <br/>:replace<br/>set string1=%~1<br/>set string2=<br/>set j=0<br/>:Loop<br/> call set inchar=%%string1:~%j%,1%%<br/> if "%inchar%"=="" goto ExitLoop<br/> set outchar=%inchar%<br/> IF "%inchar%"=="X" set outchar=Y<br/> IF "%inchar%"=="x" set outchar=y<br/> set "string2=%string2%%outchar%"<br/> set /a j=%j%+1<br/> goto Loop<br/>:ExitLoop<br/>echo %string2% &gt;&gt; newfile.txt<br/>goto :eof<br/> Alternative in which a one-line VBScript is created, used and destroyed; it will run slightly more slowly. Note that FOR loop metavariables are case sensitive, so %%A will not interfere with %%a. Note also that the first FOR loop can be one line. <br/><br/>Code: <a>[Select]</a>@ECHO OFF<br/>REM ====================================================<br/>REM Code to change every occurrence of 'X' to 'Y' --<br/>REM in every line of 'Test-myfile.txt'...<br/>REM ====================================================<br/>echo wscript.echo Replace(wscript.arguments(0), wscript.arguments(1), wscript.arguments(2))&gt;Srep.vbs<br/>@ECHO OFF &gt; newfile.txt<br/>FOR /F "tokens=1,2,3,4,5,6,7-15* delims= " %%a in (Test-myfile.txt) DO call :replace "%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m %%n %%o"<br/>ECHO Done!<br/>del Srep.vbs&gt;nul<br/>pause<br/>exit<br/> <br/>:replace<br/>set string2=%~1<br/>for /f "delims=" %%A in ( ' cscript //nologo Srep.vbs "%string2%" "X" "Y" ' ) do set string2=%%A<br/>for /f "delims=" %%A in ( ' cscript //nologo Srep.vbs "%string2%" "x" "y" ' ) do set string2=%%A<br/>echo %string2% &gt;&gt; newfile.txt<br/>goto :eof <br/> ST, thanks again for the 2 solutions which you provided -- both of which preserve case sensitivity.<br/><br/>Am I right in assuming that the use of double-quotes in the [SET "string2=%string2%%outchar%"] statement -- in the non-VBS version -- is a way of ensuring that spaces, currently at the end of the string being processed, are not lost?Quote from: TomTheCabinBoy on May 11, 2011, 04:59:14 AM</p><blockquote>ST, thanks again for the 2 solutions which you provided -- both of which preserve case sensitivity.<br/><br/>Am I right in assuming that the use of double-quotes in the [SET "string2=%string2%%outchar%"] statement -- in the non-VBS version -- is a way of ensuring that spaces, currently at the end of the string being processed, are not lost?<br/></blockquote><br/>Yes, that is correct. The SET command used without quotes ignores trailing spaces, so to be sure that, if %outchar% should happen to be a space, it is added, the quotes are used as you saw.<br/>[Update] I tested the batch without quotes in that line, and it seems to work just the same. I think I just assumed you needed them.<br/>ST, you warned me, in your initial reply, that "poison characters" embedded in text strings can cause problems when <a href="https://interviewquestions.tuteehub.com/tag/processing-25579" style="font-weight:bold;" target="_blank" title="Click to know more about PROCESSING">PROCESSING</a> them in batch scripts. Sure enough, when my test text file was modified to contain ampersands [&amp;], percent signs [%], and double quotes ["], in <a href="https://interviewquestions.tuteehub.com/tag/addition-238198" style="font-weight:bold;" target="_blank" title="Click to know more about ADDITION">ADDITION</a> to the dreaded exclamation marks [!], problems were encountered. Sorry to say, all 3 of your solutions -- which worked fine for exclamation marks [!] -- failed when processing the aforementioned additional rogue characters.<br/><br/>I think you might be interested in a solution, I have developed, which seems to cope with all of the above "poison characters". It is based on some of your conversion code (but after many experiments with combinations of enabling/disabling delayed expansion, and in or out of sub-routines). I have commented the script as a reminder of how different methods work, or don't work, in certain situations.<br/><br/>My input file [Test-myfile.txt] now contains...<br/><br/>Code: <a>[Select]</a>Line 01 containing x but not X!<br/>Line 02 containing A but not X!Watch this space!x<br/>Line 03 containing X but not Y! and another xylophone.<br/>Line 3A containing X and 1st percent % sign, 2nd percent % sign, and 3rd percent % sign.<br/>Line 3B containing X and just 2 percent % signs. (Here's the 2nd percent % sign).<br/>Line 3C containing X and 1st percent ^% sign, 2nd percent ^% sign, and 3rd percent ^% sign.<br/>Line 3D containing X and just 2 percent ^% signs. (Here's the 2nd percent ^% sign).<br/>Line 04 containing X and Y and another x and a word like axiom.<br/>Line 4A containing x and an ampersand &amp; and another &amp; followed by one more &amp; and a percent % sign.<br/>Line 4B containing x and an ampersand &amp; on its own.<br/>Line 4C containing 2 ampersands -- this one &amp; and this one &amp; as well.<br/>Line 05 containing Y but not x; also an upper-case 'X' in single quotes<br/>Line 5A containing W but not X; also a lower-case "x" in double quotes<br/>Line 06 containing Xxx (but not Yyy):<br/>Line 07 containing B and Z and Y~<br/>Line 08 containing Y but not X#<br/>Line 09 containing X and Y and another Xylophone<br/><br/>My MS-DOS batch code is now as follows...<br/><br/>Code: <a>[Select]</a>@ECHO OFF<br/>REM ====================================================<br/>REM Code to change every occurrence of 'X' to 'Y' --<br/>REM in every line of 'Test-myfile.txt' -- without losing --<br/>REM 'special characters'. e.g. [!][%][&amp;][#][~]["]['].<br/>REM Preserving upper/lower case is selectable.<br/>REM ====================================================<br/><br/>REM Display/obtain case preservation options/choice...<br/> ECHO.<br/> ECHO When changing 'X' to 'Y' should the original case be preserved?<br/> ECHO.<br/> ECHO [0] Case-preservation is not important. (Default - Quicker)<br/> ECHO [1] Preserve original case. (Slower)<br/> ECHO.<br/> SET /P CASE_CHOICE=Enter option...<br/> ECHO.<br/> IF "%CASE_CHOICE%" EQU "1" ECHO Original case will be preserved. (Slower option)<br/> IF "%CASE_CHOICE%" NEQ "1" ECHO Original case may not be preserved. (Quicker option)<br/> ECHO.<br/> PAUSE<br/><br/>REM Initialise a count for lines processed.<br/> SET LINES_COUNT=0<br/><br/>REM Create an empty Output File.<br/> @ECHO OFF &gt; newfile.txt<br/><br/>REM One at a time, read each complete line of the Input File into a single string.<br/> FOR /F "tokens=1* delims=" %%a in (Test-myfile.txt) DO (<br/>REM ECHO Original line..."%%a"<br/>REM At this point, complete string is intact.<br/><br/>REM Copy the complete intact string --<br/>REM enclosing in quotes to protect special characters (most).<br/> SET string1="%%a"<br/>REM At this point, string1 contains the complete intact quoted string --<br/>REM but appears to be empty/undefined if echoed.<br/><br/>REM For each line of the Input File, string processing requires 'EnableDelayedExpansion' --<br/>REM which can only be executed a maximum of 16 times before reaching the --<br/>REM 'Maximum setlocal recursion level' (despite also executing 'DisableDelayedExpansion').<br/>REM Also, within 'EnableDelayedExpansion' %%a will lose exclamation marks --<br/>REM fortunately we no longer need %%a (for the current line) as it has been copied to string1.<br/>REM For these reasons, the main string processing is done in a subroutine...<br/> CALL :REPLACE_CHARS<br/> )<br/><br/> ENDLOCAL<br/> ECHO Done!<br/> PAUSE<br/> EXIT<br/><br/>:REPLACE_CHARS<br/><br/>REM Increment lines processed count...<br/> SET /A LINES_COUNT=%LINES_COUNT%+1%<br/><br/>REM Enable delayed environment variable expansion --<br/>REM so that the value of certain variables can be dynamically redefined at run time --<br/>REM using !Variable! instead of %Variable% (or a combination)...<br/> SETLOCAL EnableDelayedExpansion<br/><br/>REM Display progress...<br/> ECHO Original Line !LINES_COUNT! ...!string1!...<br/>REM At this point, string1 still contains the complete intact quoted string.<br/><br/>REM Ascertain whether preservation of original case is required...<br/> IF "!CASE_CHOICE!" EQU "1" GOTO PRESERVE_CASE<br/><br/>REM Original case is not required to be preserved...<br/><br/>REM Convert all 'X's in the string (line) to 'Y's -- <br/>REM upper and lower-case 'X's will be converted to upper-case 'Y's.<br/> SET string2=!string1:X=Y!<br/> GOTO WRITE_LINE<br/><br/>REM Original case must be preserved...<br/><br/>:PRESERVE_CASE<br/><br/>REM Initialise an index for the current character position --<br/>REM and an empty string to construct the converted line...<br/> set j=0<br/> set string2=<br/><br/>:Loop<br/><br/>REM One at a time, isolate each individual character in the string (line)...<br/> set inchar=!string1:~%j%,1%!<br/> IF "!inchar!END"=="END" GOTO :ExitLoop<br/><br/>REM Copy the current character for passing to the modified string (line)... <br/> SET outchar=!inchar!<br/><br/>REM Convert 'X's to 'Y's -- preserving the original case...<br/> IF "!inchar!"=="X" set outchar=Y<br/> IF "!inchar!"=="x" set outchar=y<br/><br/>REM Construct the new string (line) by concatenating the current/modified character...<br/> SET "string2=!string2!!outchar%!"<br/><br/>REM Increment the index for the next character position, and repeat...<br/> SET /A j=!j!+1%<br/> GOTO :Loop<br/>:ExitLoop<br/><br/>:WRITE_LINE<br/><br/>REM Strip-off the leading/trailing quotes from the processed string (line) --<br/>REM then write it to the Output File -- ensuring no spaces are added at end of line.<br/> ECHO !string2:~1,-1!&gt;&gt; newfile.txt<br/><br/>REM Display progress...<br/> ECHO Modified Line !LINES_COUNT! ...!string2!...<br/><br/>REM Disable delayed environment variable expansion.<br/> SETLOCAL DisableDelayedExpansion<br/><br/>REM Return whence we came.<br/> GOTO :EOFQuote<blockquote>REM For each line of the Input File, string processing requires 'EnableDelayedExpansion' --<br/>REM which can only be executed a maximum of 16 times before reaching the --<br/>REM 'Maximum setlocal recursion level' (despite also executing 'DisableDelayedExpansion').</blockquote><br/>I'm not sure what you mean by this - you only enable delayed expansion once, at any point before the loop or other structure. You don't have to re-enable it for each line that is read from a file!<br/><br/><br/><br/>Isn't this better? Sooner or later if you are doing <a href="https://interviewquestions.tuteehub.com/tag/serious-3021168" style="font-weight:bold;" target="_blank" title="Click to know more about SERIOUS">SERIOUS</a> textfile processing you are going to need to look at something else. Visual Basic Script is present in every Windows installation these days. <br/><br/>Save as a .vbs file and run with <br/><br/>Cscript //nologo yourname.vbs<br/><br/><br/>Code: <a>[Select]</a>Set fso = CreateObject("Scripting.FileSystemObject")<br/>Const ForReading = 1, ForWriting = 2, ForAppending = 8<br/>Const FormatSystemDefault = -2, FormatUnicode = -1, FormatASCII = 0<br/>ReadfileName ="Input.txt"<br/>WriteFileName="Output.txt"<br/>Wscript.echo "Read file..."<br/>Set InputFile = fso.openTextFile (ReadFileName, ForReading, FormatASCII)<br/>Set OutputFile = fso.openTextFile (WriteFileName, ForWriting, FormatASCII)<br/>Do While Not InputFile.AtEndOfStream<br/> InputLine = InputFile.readline<br/> Wscript.Echo "Input " &amp; InputLine<br/> TempLine = InputLine<br/> TempLine = Replace(TempLine, "X", "Y")<br/> TempLine = Replace(TempLine, "x", "y")<br/> OutputLine = TempLine<br/> Wscript.Echo "Output " &amp; OutputLine<br/> OutputFile.WriteLine(OutputLine)<br/>Loop<br/>InputFile.Close <br/>Outputfile.Close<br/>Set fso = Nothing<br/>Set Shell = Nothing<br/></body></html>