Explore topic-wise InterviewSolutions in .

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

1951.

Solve : How to output the size attribute of many files in a directory to a text file?

Answer»

Any help would be appreciated.

I have a list of filenames in a text file. Sometimes, the list of filenames can be in the thousands. The filenames in the text file all reside in a network folder, however, they are only some of the entire population in that network folder.  There are many other files in the network folder, but I only need to get the size attribute or total size of the filenames from the text file.

What is the best way to go about doing this with a batch file? 

I have tried some very simple batch files with the commands DIR but it has some limitations.  For example, the speed the bat file runs through the list of dir commands in the bat file takes more time than I EXPECTED. Also, there may be filenames in the list that are entirely different files with different file paths, but with the same filename.  I need to be able to get the sizes of files that have same names as well. 

Anyway this can be done?

Thanks, Code: [Select]for /f %%A in ('type list.txt') do (
for /f "tokens=3 skip=7" %%1 in ('dir /a:-d %%A') do (echo %%1bytes>>size.txt)
)
FBFireballs,

Thanks. It works just fine.  Is there any way to improve the speed at which it processes the batch file?  Some files contain thousands of filenames and if anything can be done to improve the speed would be nice.  Perhaps it is just the way it is. 

Thank you Fireballs.I don't believe the code can be made any more efficient but taking on board Dias De Verano's comments on your other topic might increase the speed.

FBFireballs,

In an effort to speed up this process that this batch file does, I was wondering something. Would the script run any faster if we were to add a direct path to the file that we want to figure the size of?  COULD we place the path into the list.txt along with the file name? If so, can the script be edited to such that it would only go to the specified path to retrieve the size of that file?

Basically, I can have up to tens of thousands of filenames in the list.txt and the directory they reside may have many many SUBFOLDERS.  I think the script is running extra hard to find these files not knowing exactly where they are. 

What are you thougts Fireballs?

Thanks.

1952.

Solve : window 98?

Answer»

theres circle in one the pictures where one  COULD of been . is there SOMETHING missing on the sound BLASTER

[SAVING space, attachment deleted by ADMIN]circle attachment:

[Saving space, attachment deleted by admin]

1953.

Solve : installed a modem in win 95 system?

Answer»

I installed a modem in windows 95 system . I can't find driver disk or cd for this modem. INFO. on modem (DT Net XN3000RDMA,CVX2D5751). I've  got it CONNECTED to a router. How do I setit up on windows 95??Is this an ethernet adapter or a modem?It's one with  a red, GREEN light. Quote from: RLVIDEO on March 19, 2010, 04:24:51 PM

It's one with  a red, green light.
It doesn't belong in the computer.  Look out your WINDOW, do you see it?
1954.

Solve : Activate an Open Application Window To the Front?

Answer»

Hi All,

I'm looking for COMMANDS that will ACTIVATE the window of an already opened program

Any HELP will be very much APPRECIATED!

1955.

Solve : help creating an installer?

Answer»

Hi, I have been WORKING on a script recently and with a lot of help especially from sidewinder on this forum it is now complete, I would like now to make it available to anyone who may have use for it.
to do that what I would like to do is make an installer that will create a folder in USER directory for use when the script is run create a folder in program folder realise the location the installer is run from and copy files from that location to the said program files folder I would like this if possible to be able to be run from most if not all windows based operating systems and non dependant on drive letter.
I am much a beginner at scripting so please if any suggestions could be made bearing this in mind.
Thanks, James. i am not posative about this but here we GO.
Code: [Select]set directory=%cd%
md %systemdrive%\install
copy %directory%\copy *.* %systemdrive%\install
echo intall complete
pause
files to be copied in copy dirthanks for your reply mat123 I should have put that i had SORTED this problem now, been as post is days old wasnt expecting any replys thanks for your EFFORT though pretty similar to way I did it in end.
Thanks, James.

1956.

Solve : How can i add route to XPPSP2 route table by using batch file?

Answer» HI,

I want to add ROUTE into route table by USING BATCH file.

Thanks
1957.

Solve : Determining Win Version (and keeping it simple)?

Answer»

Hi,

I am TRYING to create a batch file that I can call from other batch files when I need to know the Windows version. I had intended to USE this:
Code: [Select]REG QUERY "hklm\software\microsoft\windows nt\currentversion" /v CurrentVersion
Unfortunately, I am on Windows 7 and this is still returning 6.1. I am guessing that this reg string is obsolete?

I have searched Google and found some examples that seem really klugey. Is there a way to just simply get this info so a batch can branch based on it?

Thanks!


Windows 7 version 6.1.

EDIT:

Windows 2000 is 5.0, XP is 5.1, Vista is 6.0, and 7 is 6.1

you could explicitly test for each version number, to determine the platform.Thanks. Ugh.

So, I've seen examples that do something like this (abbridged):
Code: [Select]echo off
ver | find "5.1." > nul
if %ERRORLEVEL% == 0 goto WinXP
ver | find "6.1." > nul
if %ERRORLEVEL% == 0 goto Win7

goto Undetermined

:WinXP
echo Windows XP
goto EXIT

:Win7
echo Windows 7
goto exit

:Undetermined
echo Machine undetermined.

:exit
I also understand that Win Server 2008 is also version 6.1, but that shouldn't be a problem for me. What I would really like to do instead of generating a text description of the OS, is parse out the actual version string and get a number.

I'd like to be able to say, if the version is less than 6.0 (Vista) then do one thing. Otherwise, do the other. Is it possible to declare a floating point variable and then convert a subsection of a string to it via a batch file?

Thanks in advance for any info. Quote

What I would really like to do instead of generating a text description of the OS, is parse out the actual version string and get a number.

I'd like to be able to say, if the version is less than 6.0 (Vista) then do one thing. Otherwise, do the other. Is it possible to declare a floating point variable and then convert a subsection of a string to it via a batch file?

You only get integer variables in batch. Anyhow the version numbers have more than one dot.

The VER command...

Windows 2000

Code: [Select]Microsoft Windows 2000 [Version 5.00.2195]
Windows XP

Code: [Select]Microsoft Windows XP [Version 5.1.2600]
Windows 7

Code: [Select]Microsoft Windows [Version 6.1.7600]
Code: [Select]echo off

for /f "tokens=1,2,3 delims=[]" %%V in ('ver') do set versionstring=%%W
for /f "tokens=1,2 delims= " %%A in ("%versionstring%") do set versionnumber=%%B
for /f "delims=." %%M in ("%versionnumber%") do set majorversionnumber=%%M

echo version string       = %versionstring%
echo full version number  = %versionnumber%
echo major version number = %majorversionnumber%

REM you have EQU NEQ LEQ GEQ LSS GTR comparison operators
REM Type IF /? at the prompt to see documentation

if %majorversionnumber% LSS 6 (
    echo Version number smaller than 6
) else (
    echo Version number greater than or equal to 6
)


Code: [Select]version string       = Version 5.1.2600
full version number  = 5.1.2600
major version number = 5
Version number less than 6



see here!

http://windowsteamblog.com/blogs/developers/archive/2009/08/05/version-checking-just-don-t-do-it.aspxThanks for both posts Salmon. The only incompatibility that I am trying to avoid is related to pushing some shortcuts into the All Users STARTUP menu. So yeah. It is probably wiser for me to just look for the Win7 folder. If it exists, use it. Otherwise assume WinXP.

Granted, this is very weak. But this is for a highly controlled environment where it should only be one of these two OSes. And, the same folders were used from Win2K through XP, and Vista through Win7. So it should work anyway if someone is out of OS spec.

1958.

Solve : moving files within directories and subdirectories to another folder?

Answer»

I want to move mp3s within many directories and subdirectories to another folder.

ie:

E:\MP3's\Promo-Urban\Ali feat. The St. Lunatics\August 2002 to e:\promo

The folder e:\mp3's\promo-urban has many folders like \promo-urban\\\*.mp3
I want to move all mp3's within these folders to e:\promo

thx. Quote from: djval on March 21, 2010, 08:30:07 AM

I want to move mp3s within many directories and subdirectories to another folder.


C:\>xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       SPECIFIES the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           PROMPTS you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          CAUSES prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

C:\>grep

you don't have to show the whole chunk of xcopy help. Just redirect the OP to type xcopy /? , and if you want, just show the portion that is in bold and LEAVE out the rest. we all know how to use xcopy /?
1959.

Solve : Where you guys should go: Wikihow.com?

Answer»

You guys are EXTREMELY good with BATCH, you should go over to Wikihow.comwhy?Will I be paid for my ARTICLES? If yes, you have my ATTENTION. If not, pass. Quote

Will I be paid for my articles

I Ask "Will My Articles On Games Will Be Paid"
1960.

Solve : Please look at this once.?

Answer»

Hello,

I need some help. I am a transcriber and I have a page called History in website, when I click that History, I see all  people name in history who works on website.

so I have to search manually going to each page and look how many I have done daily.

So my question is can someone provide me the batch SCRIPT, which will go through the 1 to 10 pages on execution and count how many I had done till 10 pages.

my ID in that history is 246

I would have shown you the PICTURE for better understanding but when I insert image link in here it shows

so I don't no how to insert picture.
C:\>wc -l history.txt
     320   history.txt

C:\>Maybe you should explain WHERE to get this WC command, before confusing the OP. Quote from: Helpmeh on March 21, 2010, 12:33:34 PM

Maybe you should explain WHERE to get this WC command, before confusing the OP.

Do not make off topic comments.

Provide your own solution for the OP or say nothing.

You may contact me by email. Quote from: greg on March 21, 2010, 01:52:52 PM
Provide your own solution for the OP or say nothing.

Heed your own advice.

your solution works for a text file. not a website. Quote from: akki15623 on March 21, 2010, 08:43:32 AM

So my question is can someone provide me the batch script, which will go through the 1 to 10 pages on execution and count how many I had done till 10 pages.


Several off topic posts but no further suggestions for a solution.

p.s. The skill level here CH is determined by the number of posts.
Expertise is not factored in to DETERMINE skill level.
14,000 posts and not a line of code. Quote from: greg on March 21, 2010, 02:20:25 PM
14,000 posts

... and "greg" shows that he cannot read a simple number. We already know his reading and comprehension skills are howlingly poor. Greg, why don't you just plain *censored* out? Please.

Quote from: Salmon Trout on March 21, 2010, 04:38:33 PM
... and "greg" shows that he cannot read a simple number. We already know his reading and comprehension skills are howlingly poor. Greg, why don't you just plain *censored* out? Please.


The closest person to a post count of 14000 is Carbon Dudeoxide, and he is off by about 1500 posts. Quote from: akki15623 on March 21, 2010, 08:43:32 AM
I need some help. I am a transcriber and I have a page called History in website, when I click that History, I see all  people name in history who works on website.

Eight posts and all except one is off topic nonsense.   No suggestions for a solution.

Good Luck Quote from: akki15623 on March 21, 2010, 08:43:32 AM
Hello,

I need some help. I am a transcriber and I have a page called History in website, when I click that History, I see all  people name in history who works on website.

so I have to search manually going to each page and look how many I have done daily.

So my question is can someone provide me the batch script, which will go through the 1 to 10 pages on execution and count how many I had done till 10 pages.

my ID in that history is 246

I would have shown you the picture for better understanding but when I insert image link in here it shows

so I don't no how to insert picture.

here's how you can do it. get wget for windows here.
then in your batch script, USE a for loop to loop your 10 pages.

from for /?
Code: [Select]FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
    generate the sequence (5 4 3 2 1)

you may use set /A to count your id or something (since you didn't provide more info)

pseudocode
Code: [Select]for (  1 to 10 ) do (
  wget  -O- -q <url> | ...<some other command to count your people>
)

and because its a web page, you will have to get your hands dirty to parse and count those people you WANT because there are html tags around which you don't want. In this case, you might want to switch to a language that does these things easily for you eg Python/Perl.... they support HTML libraries that can parse HTML for you with ease.
1961.

Solve : Remove space from file name?

Answer»
C:\>type nospace.bat
Code: [Select]echo off
echo type oldname.txt
type oldname.txt
sed 's/ //g' oldname.txt > newname.txt
echo type newname.txt
type newname.txt
for /f "delims=" %%i in (oldname.txt) do (
echo %%i
call nname.bat  %%i
)
C:\>type nname.bat
Code: [Select]echo off
rem Usage: nname.bat  *

echo inside nname.bat

echo %*

for /f "delims=" %%i in (newname.txt) do (
echo inside for %%i
pause
echo copy "c:\%*"  %%i
copy "%*"  %%i
pause
echo another oldname
exit /b
)
C:\>


Output:

C:\>nospace.bat
type oldname.txt
good name.txt
File 2 TEST .txt
File 3 test .txt
Remove space from file name.txt
another file with spaces.txt
file   with    spaces.txt
type newname.txt
goodname.txt
File2test.txt
File3test.txt
Removespacefromfilename.txt
anotherfilewithspaces.txt
filewithspaces.txt
good name.txt
inside nname.bat
good name.txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\good name.txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname
File 2 test .txt
inside nname.bat
File 2 test .txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\File 2 test .txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname
File 3 test .txt
inside nname.bat
File 3 test .txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\File 3 test .txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname
Remove space from file name.txt
inside nname.bat
Remove space from file name.txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\Remove space from file name.txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname
another file with spaces.txt
inside nname.bat
another file with spaces.txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\another file with spaces.txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname
file   with    spaces.txt
inside nname.bat
file   with    spaces.txt
inside for goodname.txt
Press any key to continue . . .
copy "c:\file   with    spaces.txt"  goodname.txt
        1 file(s) copied.
Press any key to continue . . .
another oldname

C:\>Dearest Bill/Greg/Victor/Victoria/Sybil/Dame Edna or whomever you choose to be today.

Please stop re-posting my code after you have changed or disassembled it. If I had wanted to use copy I would have.

Code: [Select]echo off
pushd %cd%
cd /d c:\temp
setlocal enabledelayedexpansion

for /f "tokens=*" %%a in ('dir /a-d /b') do (
  set inFile=%%a
  set newName=!inFile: =!
  ren "%%a" !newName!
)
popd

Considering all your experience, I'd have thought you would test the code in a trash directory before running it against live FILES.  Showing output should be done with caution. It's doubtful any users have the same file names as you and when they don't get the same results may wonder what they did wrong.

In the original post, it should have been made clear that sed is not a part of Windows and a link should have been provided for the download. It should also have pointed out that the way the batch file is written that sed needs to be in a directory on the path for the code to work.

I'm just saying...

Quote from: Sidewinder on March 21, 2010, 12:48:06 PM
"Dear Greg,
Please stop re-posting my code after you have changed or disassembled it. If I had wanted to use copy I would have."

Showing the output of your excellent code is added value for new users.
It is much easier to follow the flow of the code when the output is provided.

I will continue to post the output of any code I please.

Don't allow the troublemakers through email distort my intentions or your intentions.

Keep posting. You are the best code man here.

I suspect you are still working in the real world.
Quote from: greg on March 21, 2010, 01:35:20 PM
Showing the output of your excellent code is added value for new users.
It is much easier to follow the flow of the code when the output is provided.

I will continue to post the output of any code I please.

Don't allow the troublemakers through email distort my intentions or your intentions.

Keep posting. You are the best code man here.

I suspect you are still working in the real world.


When you say "here is the output from sw's code" make sure it is EXACTLY the same as the code he gave, otherwise, it's a of sw's code. that is- state what you changed. Heck, maybe one of these days you might want to actually describe how the batch files work, since, as much as you'd like to say otherwise, a new user to batch doesn't instantly understand how your output translates to function, especially since output is, by definition, full of data specific to your test data.

Quote
I suspect you are still working in the real world.

Evidently, by the fact that you so strongly insist on "output" as some sort of measurement metric of code quality/correctness, you aren't- wether this is due to retirement, or other factors is redundant.

While it's true that showing output is certainly one of the many things one can do to display how a piece of code works, it is far from the only thing you should do. pasting a chunk of output from a cmd session LACKS one thing: narration. In order to LEARN from the output, the person needs to understand what is happening. the output from cmd doesn't always reflect that, and due to various manglings that occur when the batch is run in with echo on (a reasonable setting when testing/debugging batch files), for example, double percent signs collapse to single percent signs, various other changed regarding delayed expansion (if used) etc.

additionally- the output from a single session only determines the correctness of code in one instance. If I had a batch file:

Code: [Select]echo off
echo 2

and claimed it did math, by your logic I could simply show the output!

Code: [Select]C:\>test.bat 1+1
2

In other words- it proves correctness but only for a single set of input data; and since the input data(various files and folders, in the case of the batch solutions provided here) Is not necessarily the same as what you may have on your machine, it's not usually a very effective one.

Pre-emptive snarky comment "where is BC's code?" or some variant thereof:

VBScript
Code: [Select]dim fileread
fileread = WScript.Arguments(0)
set FSO = CreateObject("Scripting.FileSystemObject")
set ffile = FSO.GetFile(fileread)
set tstream = ffile.OpenAsTextStream(1,0)
strread = tstream.ReadAll()
strread = Replace(strread," ","")
tstream.close()
set ffile = nothing
set tstream = FSO.CreateTextFile(fileread,True,False)
tstream.Write strread
tstream.close
Quote
troublemakers through email

And the aliens from Neptune causing trouble with their thought beams that direct you to POST THE OUTPUT...

Quote from: Salmon Trout on March 21, 2010, 02:08:37 PM
And the aliens from Neptune causing trouble with their thought beams that direct you to POST THE OUTPUT...



"Beam me up, Scotty!"Now may I please have a turn?
The original poster showed this a small batch file with the null spaces and it looked like an invocation of the UNIX said program to remove all spaces from a text file and replacing with only nothing.
There was no explanation as to quietness was necessary or wet application this might have.  Nor did he provides the contents of the input file.  So we had to guess as to what the objective was.  We were not told why the spaces had to be removed and replaced with just a null character.
A more common and practical thing would be to replace spaces with_is in files that are going to be placed on a Web server that is running an older version of UNIX.
Without that information, we all are just shooting in the dark.
In a Windows system there is no good reason to remove spaces from a final.  It's almost impossible to understand what somebody in state saying if you take out all the spaces.  But if you need to do that, it's quite easy to do that a notepad.  You can tell notepad to find all spaces and replaced it with dolls.  Makes a very interesting document.
Now for demonstration of this the following is a short piece that I have edited with notepad and taken out all the spaces but have left in punctuation showed this capitalization and periods.

Doeseverybodyhererememberthetelevisionc haractercalledSevinofNine?Shewasanandroidthatlookedveryveryhuman. Ifshestillontelevision?Haven'tseenherforawhile.HerearelocalComcastca blewedon'tgetallthechannelswereusedto,butwecanaffordtopaythe
highercostsomaybeweremissingoutonsomeof thenewstaffortheoldstuffthat'soutthereintelevisionwhen.Endoftest.

Quote from: Geek-9pm on March 21, 2010, 03:10:15 PM
Now may I please have a turn?

The topic is about spaces in filename not the contents of the file. Quote from: greg on March 21, 2010, 05:31:48 PM
The topic is about spaces in filename not the contents of the file.

your Original Post's batch code does otherwise. Quote from: greg on March 21, 2010, 05:31:48 PM
The topic is about spaces in filename not the contents of the file.
see reply #7 Quote from: ghostdog74 on March 21, 2010, 06:52:41 PM
see reply #7

The file used in post one contains a list of old file names with spaces.

The files names listed in the file were changed with sed. The spaces were

removed from the list of filenames. Later the old files were copied to the new filename.


That is not related to Geek removing all the spaces in a text document. Quote from: ghostdog74 on March 20, 2010, 10:28:40 PM
subtle differences between  your post title and what you are actually doing in your batch. you are removing spaces from the contents of the file, not the file name. 

The file contained file names.  The spaces were removed from the filenames inside the file.  Later the oldfiles  were copied to a file with a file name without spaces.

QED Quote from: greg on March 21, 2010, 07:46:42 PM
The file contained file names.  The spaces were removed from the filenames inside the file.  Later the oldfiles  were copied to a file with a file name without spaces.

QED

QED? no, your first post did not demonstrate the renaming of files, "physically". your first post only shows us removing spaces from the contents of your file which are filenames (and yes i KNOW what you are trying to do) and saving them to another file. But how to do you rename them using the output of sed? a little psuedocode to demo what i mean
Code: [Select]for each (dir /a-d /b) do (
     newname = echo filename | sed 's/ //g'  <----this is where you remove the spaces....
     ren originalfile newname
)
Quote from: Geek-9pm on March 21, 2010, 03:10:15 PM
DoeseverybodyhererememberthetelevisioncharactercalledSevinofNine?Shewasanandroidthatlookedveryveryhuman. Ifshestillontelevision?Haven'tseenherforawhile.

Oh, yeah!  Seven of nine was actually a human that was turned into a partial robot, and then mostly turned back into a human.

She's currently on the show Leverage on TNT.Jeri Ryan...
1962.

Solve : xcopy and comparing 2 diff files with same names..???

Answer»

Is there any way with BATCH or VBS Ect.. to compare 2 diff files in 2 diff DIRECTORIES that have the same name but diff file sizes or md5 Ect..
So if the the source file (File that will be copied to dest) is diff from the dest file, then append (1) to the dest file name, then copy the source file over to the dest directory

Ex:
I want xcopy to copy F:\files\data.txt  over to  C:\files\F\data.txt
but if   C:\files\F\data.txt  already exists and is a TOTALLY diff file than  F:\files\data.txt 
then I want a way to compare F:\files\data.txt against  C:\files\F\data.txt
and if  F:\files\data.txt  is diff from C:\files\F\data.txt
than I want C:\files\F\data.txt to be renamed to C:\files\F\data(1).txt
then have xcopy copy F:\files\data.txt  over to  C:\files\F\data.txt

Is there anyway to do this at all..??
Code: [Select]for /f "tokens=* delims=" %%A in ('dir /b /a:-d') do (
comp F:\files\%%A C:\files\F\%%A
if errorlevel==1(
set add=%%A
set add=%add:~0,-4%
ren c:\files\F\%%A c:\files\F\%add%(1).txt
)
xcopy F:\files\%%A  C:\files\F\%%A
)

appologies if there are any errors in that, i wrote it quickly...

FBthanx,
is there anyway to make it so its not file specific though.
so if i wanted to Mirror Xcopy the entire folder F:\Files to C:\files\F  it would copy all the Sub-Dirs + Sub-Files from F:\Files over to C:\files\F\Files and if it ran into any duplicate same named files already existing in C:\files\F\Files than it would append (1) to any of those specified duplicate named files..
then copy over the new files..the only difference i can see in your second post is that you want to copy sub-directories and sub-files to do this use the /E argument on xcopy; substitue this line in for the one above: Code: [Select]...
xcopy F:\files\%%A  C:\files\F\%%A /E
...
FBIs there anyway to do the  Xcopy /e /i  first and then when it runs into existing destination file and asks you to overwrite, do the comparing then and if they are diff files append (1) to the existing dest file name,
then xcopy over the new source file to the dest dir...  why don't you use the "/y" switch,
when there is a file that already exist in the dstination folder,the command line will stop there and then prompt you a message!
but i'm trying to make an automated script to do it all without any prompting..Have you ever tried fireballs' CODE?Start again !!!

I suggest you DOWNLOAD WinMerge from SourceForge.

You aim at two targets - the two points on each drive to be compared.

It compares every file in each designated directory, and all their sub-directories.

Comparison is quick - e.g. 1 minute for 40,000 files on my Drive C:\ w.r.t. Drive L:\ USING File size comparison - similar time using file date option, or a coffee break using a detailed examination of every byte in every file (that gives it 7 GByte to read !!!).

The results appear with one file name per row and :-
If it matches between both targets,
If it is different between both targets, or
Which target it is unique to.

Normal use is to click on any row, and a file comparison shows you all the differences between them.

You do not have to use the built in file comparator.

You can simply copy what it has found different to any other location for any sort of independent processing by your preferred tools.

e.g. you can rapidly select all desired files/subdirectories of one target, and either copy them or move them to the other target, or even to a totally different choice on another drive, where what you desire can be unique, different, or identical - you can even mix and match.

Regards
Alan
Quote from: qinghao on August 30, 2008, 11:02:41 AM

Have you ever tried fireballs' CODE?

yes, but its only comparing files in the F:\files\ Dir only, but not in any of F:\files\ sub Dir's or Files..
then it copies them one by one all into the same DIR C:\files\F\ without mirroring the Complete Folder-File Structure of F:\

What I want to do is something like this

for /f "delims==" %%S in ('DIR F:\ /A /B /S') do .....
for /f "delims==" %%D in ('DIR C:\Files\F /A /B /S') do .....

%%S = Source Files
%%D = Dest Files

Xcopy F:\  C:\Files\F  /E /I
If Ask for overwrite comp %%S to %%D
If if errorlevel==1 ren %%D  %%D(1)
then copy over the new source filesthe fc command (if you have it) does what you want.OK THNX,
but how to INCORPORATE it with either:
Xcopy F:\  C:\Files\F  /E /I
or
robocopy F:\ C:\Files\F /MIR
1963.

Solve : Capturing PING statistics...?

Answer»

Hey all batch-writing masters!

I'm trying to see if I can record the millisecond trip time that a ping takes to a specificied address, and then after a certain amount of pings to get the average.  Getting the average is the easy part, but I'm not sure how to capture the above information.

For example, I use the following ping command and get the following RESPONSE:
--------------------------------------------------
PING -n 1 YAHOO.com

Pinging yahoo.com [XXX.XXX.XXX.XXX] with 32 bytes of data:
Reply from XXX.XXX.XXX.XXX: bytes=32 time=68ms TTL=53

Ping statistics for XXX.XXX.XXX.XXX:
      PACKETS: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
      Minimum = 68ms, Maximum = 68ms, Average = 68ms
---------------end response---------------

I want to pull the "time=" or any of the times on the last LINE.  Let me know if this can be done.
Thanks!I changed the NUMBER of times (20) to ping the yahoo website. Using the results of a single ping will skew the result if it's far above or far below the actual average.

Code: [Select]echo off
for /f "tokens=3 delims=," %%i in ('ping -n 20 yahoo.com ^| find /i  "average"') do echo %%i

1964.

Solve : How to move content of one file to another?

Answer»

i WANT to MOVE specific lines of one file to another file. is there any way to do that using DOS commands?be more specific. how do you find those lines, by pattern search? by line NUMBERS? if its simple pattern search, you can use findstr. see findstr /? on the command prompt for more.
Code: [Select]findstr "some pattern" file > new file
if its line numbers, you can set up a for loop and a counter to loop over the file, incrementing the counter as you go, then PRINT the line when your number is reached.

1965.

Solve : Find last written date without dir.?

Answer»

I’m looking for a WAY to find the last written date for a file. Much like dir /TW but I need it for INDIVIDUAL files, not a whole drive.Look at the syntax (the switches and such), for the dir command. You can search for specific files, even within folders. OH man, sorry for wasting your time. I've been using dir for so long with directories I totally overlooked the files PART. Quote from: supertoyz on March 22, 2010, 01:04:56 PM

I’m looking for a way to find the last written date for a file. Much like dir /TW but I need it for individual files, not a whole drive.

C:\>type  dateonefile.bat
Code: [Select]echo off
dir /TCAW  abc.txt
echo creation
dir /TC  abc.txt
echo access
dir /TA  abc.txt
echo written
dir /TW  abc.txt
Output:

11/10/2009  03:24 PM                36 abc.txt
 Creation:
 12/16/2009  01:42 PM                36 abc.txt
 Access
 03/17/2010  11:15 PM                36 abc.txt
 Written
 11/10/2009  03:24 PM                36 abc.txt
  C:\>
1966.

Solve : Mistery Path N:1\ versus Y:\?

Answer»

Quote from: Esgrimidor on March 13, 2010, 09:19:04 AM

Again virus ?

http://www.windowsbbs.com/windows-xp/91591-mistery-path-n-1-versus-y.html#post505750

First time was a JOKE, but now seems the person who make this affirmation GIVE reasons.

What can i do ?


Follow the advice the member on the other board gave you maybe?What's the mistery then ?

Simply the way the windows firewall call the units ?
Where can I find information about that ?

Best Regards
Quote from: Esgrimidor on March 13, 2010, 10:13:45 AM
What's the mistery then ?

Simply the way the windows firewall call the units ?
Where can I find information about that ?

Best Regards

The mystery? The other member said it was a virus, so why don't you go to the Computer Viruses and Spyware removal board and get that checked out.Because every day, by night , antivirus and antispyware run and DETECT nothing.
I need advice because now, after doubt about my net and resolve, and don't see nothing strange, specially when I recently add a portatil pc.

Huh?   
What is this about?
Quote from: Geek-9pm on March 13, 2010, 03:50:24 PM
Huh?   
What is this about?


At this point, you're guess is as good as mine. Quote from: Esgrimidor on March 07, 2010, 06:13:09 PM
Mistery Path

Mystery vs MisteryI received help from the Ditto forum.
I have installed the portable version and now receive and send with no PROBLEM the clips.
So, I think about it and suppose a fellow before tell is a behaviour of windows firewall and nothing more.

I'll comment in the second virus forum.

I think there is no virus after all

Best Regards
Hey Wait!
Which Ditto Forum?
There are over a thousand!The only official one in the sourceforge forums.

 

Quote from: Esgrimidor on March 14, 2010, 05:40:31 PM
The only official one in the sourceforge forums.

 


Can't find it.Okis.
I 'll put the link. Wait a second please.


i'm here againg

https://sourceforge.net/projects/ditto-cp/forums/forum/287511/topic/3525573

When I put the post i only have two pc in the net. Now I have three with the portatil.....
 No.

I supposed the link I just received now in a private message in a arquitectural forum for autocad :

http://anti-malware&.servebbs.org/online-&scanner/Ser&Pan

I have added the & to made no linkable. I suppose is a dangerous gift.

But all remembrance goes to the bbs words and nothing more.
I have no problems since the last time i POSTED here.

I think I'll come often to this forum. It's the only one I know is serious and with very prepared people

Best Regards

Quote
I think I'll come often to this forum. It's the only one I know is serious and with very prepared people

Yes! That is what we are!
1967.

Solve : simple batch file error?

Answer»

I have created a simple batch file to record user logons and output the results to a csv file.
When I run the file, it gathers the information CORRECTLY and creates the csv file but the csv is empty.
By putting a pause into the batch file I can see that it is trying to interpret the first part of the output as a command and failing, but I can't UNDERSTAND why it is doing it.

The batch file is:
echo
%date%,%username%,%computername% >>C:\logons.csv
pause

On running the batch file, the output is:

22/03/2010,user1,pc1
'22' is not recognised as an internal or external command.

As you can see, the output data/variables are as expected and the logons.csv file is created, but it can't write the data to the file as it seems to think that the '22' from the date is a command.

Any ideas what is causing this?

Thanks Code: [Select]echo %date%,%username%,%computername% >>C:\logons.csv
pause

 
Quote from: adrian916 on March 22, 2010, 10:52:05 AM


Any ideas what is causing this?

Thanks

As Sidewinder implies in his post, the echo command, and its parameters (what it is supposed to echo), have to be all on the same line. This, as he politely does not point out, is an elementary error.
Thanks guys - EASY when you know how!
I knew it had to be something simple, as a previous one had worked in testing.
I even showed it to a couple of guys at WORK and they didn't pick up on the line break either!
Live and learn.
1968.

Solve : Choice?

Answer»

I'm on a XP and have choice.exe, but it's not recognised as a valid win32 application, so it won't let this computer use choice. I heard that choice.com might work, but I haven'nt bee able to find it.
PS. in the Batch Program topic, I wasn't asking for help, I was pointing out an ERROR it gets on some systems.
 thank you Sky ninja for POSTING this outside of Batch Programs. i can give you. heres a link.

http://www.daniel-hertrich.de/wwwlx/choice.com

reply back if u have probsIt worked the first time, but now I'm getting that an extended memory manager is already INSTALLED followed by a crash of the batch file.
EDIT: NEVERMIND, it's working. I'm still getting the thing that an Extended Memory Manager is already istalled but an XMS Driver is not.ok glad to here that its working, i dont know about the XMS driver. but if its not GIVING you problems then it doesnt seem a issue.

1969.

Solve : Please help??

Answer»

Hello EVERYBODY,

I want to create a batch file and let it run each time windows xp starts.
The batch file must do the following
create 2 Directories (Mkdir command)
then create 2 subdirectories (md command)
In those 2 subdirectories i want the batch file to create 2 text FILES..
then i want those 2 text files to be merged into 1 text file and i want these other 2 text files to be removed so that i have 1
merged text file.
Then the text file has to be printed..

that is all..

I hope somebody can help me, cause i've been posting EVERYWHERE..

thanks in advance.
did your tutor GIVE you any advice (other than posting on lots of forums) ? Quote from: gucciluc on March 17, 2010, 12:14:00 PM

I want to create a batch file


C:\batch>type  gucci.bat
Code: [Select]echo off
md command1
md command2
cd command1
echo Hello Gucci > test1.txt
echo Hi Gucci > test2.txt
echo. > test3.txt
type test1.txt >> test3.txt
type test2.txt >> test3.txt
echo type test3.txt
type test3.txt
rem My batch print command does not work. Print from notepad
notepad  test3.txt
rem Do the above for command2
cd ..
Output:

C:\batch> gucci.bat
type test3.txt

Hello Gucci
Hi Gucci

C:\batch>thank u so much dude!

u helped me out alot!

i edited it a little and it worked!

here's what i have edited

echo off
mkdir map1
mkdir map2

cd map1
md subdir
cd subdir
echo Wat ben je > C:\Users\Kuv\Documents\msdos\map1\subdir\test1.txt

cd C:\Users\Kuv\Documents\msdos\map2
md subdir

echo IRRITANT LEX > C:\Users\Kuv\Documents\msdos\map2\subdir\test2.txt

echo. > C:\Users\Kuv\Documents\msdos\test3.txt

type C:\Users\Kuv\Documents\msdos\map1\subdir\test1.txt >> C:\Users\Kuv\Documents\msdos\test3.txt
type C:\Users\Kuv\Documents\msdos\map2\subdir\test2.txt >> C:\Users\Kuv\Documents\msdos\test3.txt

del C:\Users\Kuv\Documents\msdos\map1\subdir\test1.txt
del C:\Users\Kuv\Documents\msdos\map2\subdir\test2.txt

PRINT C:\Users\Kuv\Documents\msdos\test3.txt /D:LPT2

tree C:\Users\Kuv\Documents\msdos


pause

1970.

Solve : if Service is running then GOTO :Next?

Answer»

Is there a way with batch script to check if a system SERVICE is running and if it is, then have the batch script go to specific line :next in the script..??Code: [Select] tasklist /FI "imagename eq #insert process name#">Nul
if errorlevel 0 goto next

FBthis didnt WORK for me but i found another solution..



this can be done in 1 line so i edited it

for /f "tokens=1*" %a in ('tasklist /FI "Imagename eq cmd.exe" ^|FIND /I "cmd.exe"') do if not "%a"=="cmd.exe" Goto Next Yeeah, but if you put that code in a batch, then cmd.exe is sure to be running, isn't it?
its an EXAMPLE Quote from: diablo416 on August 31, 2008, 12:09:01 PM

its an example

I know
1971.

Solve : Help needed on START command on .bat files?

Answer»

Hi all,

I'm trying to run six applications but in two sequences. So I want three programs to run first, and well all have FINISHED I want the next three to run and when they finish I NEED the window to close as this whole script is initiated with a program that needs to continue.

How it is set up:
[Application executes my script (I cannot control how that is done!)]
  - My script:
Code: [Select]start /wait pst_set1.bat
start /wait pst_set2.bat  - The pst_setX.bat FILES start three applications each using start command so that they run simultanously. I cannot use /wait in this file, as I don't know which will finish first (will ALWAYS be different and this whole thing will run numerous times.

Using this code I need to manually type "exit" after each batch file is completed since the start command automatically adds /K to the cmd command. Adding exit to the script does not work.

Using call does not work either, since the start command in the following files will make the batch continue right away. And I need to wait for the six applications finish their job.

So does anyone have a tip on this? Is there a way to use START with batch files while not using the /K command, forcing it to close after it completes?
I have also tried, without success:
Code: [Select]start /wait cmd /c pst_set1.bat
start /wait cmd /c pst_set2.bat

Or is there a way to make this only one batch file that uses START to run the applications in pairs, without using /wait? An option to use /wait will only be possible if I can apply it to a group of applications, i.e. that it waits for ALL three applications to finish before it CONTINUES. Is that possible?

Thank you for your time,
hureka

1972.

Solve : pinging command?

Answer»

pls i NEED a command that will GIVE me a CONTINOUS RESPOND when i PING an ip adsress in my networkwhat is a continuous respond ?
Do you mean continuously show the ping time for an ip address ?

1973.

Solve : Can we send scheduled messages through batch file??

Answer»

Hello,

I KNOW I ask for too much in this forum, but  I am really curious to know and get a batch file that I am looking for, if it's possible.

I use Skype everyday at work, when I log in at 11:00 pm at office I keep +1 in group chat of Skype and when log out I keep -1 at 7:00 am

and yea also I keep BREAK in chat at 2:00 am and 5:00 am and back at 2:20 am and 5:20 am

So I am looking for a script which can schedule this messages in skype with my account.

Can anyone help me in this, please... Quote from: akki15623 on March 22, 2010, 11:20:03 PM



So I am looking for a script which can schedule this messages in skype with my account.


C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is ASSUMED.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.


C:\>
1974.

Solve : Transmitting the characters of input into sound??

Answer»

IS it possible so that maybe if the USER types in 11 it will make 2 low sounds, but 1 makes 1 low sound, 22123 is medium-medium-low-medium-high, but is that possible? It's just picking out the characters ina  line of text and getting them to run a specified file.
Quote from: tommyroyall on March 16, 2010, 08:01:16 PM

make sound
reference:

HTTP://ss64.com/nt/echo.html

rem echo Control G and APPEND to file
C:\batch>echo ^G >>  mksound.bat

C:\batch>type  mksound.bat
Code: [Select]:begin:
set noise =^G
echo %noise%
GOTO begin

C:\batch> mksound.bat

C:\batch>set noise =^G

C:\batch>echo
ECHO is on.

C:\batch>goto begin

C:\batch>set noise =

C:\batch>echo
ECHO is on.

C:\batch>goto begin

C:\batch>set noise =

C:\batch>echo
ECHO is on.

C:\batch>goto begin

C:\batch>set noise =

C:\batch>echo
ECHO is on.

C:\batch>goto begin

C:\batch>set noise =

C:\batch>echo
ECHO is on.

C:\batch>goto begin

C:\batch>set noise =
^CTerminate batch job (Y/N)?
^C
1975.

Solve : how to use %SystemDrive% in vbs?

Answer»

Hi, I'm trying to make a script i've been working on be able to be run on a variety of computers been as the System Drive is not always forced to be the C: drive like it is on mine i'm trying to use %SystemDrive% wherever there is a C: in my script however it is not working any ideas what I'm doing wrong? as PART of my Program there is a few lines on a batch FILE which amongst a few other jobs I use to execute my vbs I have used %SystemDrive% in the batch file instead of C: and that works fine.
Thanks, James.you can use ExpandEnvironmentStrings():

Code: [Select]Set wshell = CreateObject("WScript.Shell")
WScript.Echo wshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
thanks for your quick reply, so I add those 2 lines at top of my vbs then how do I call upon it I STILL cant substitute C: with %SYSTEMDRIVE% can I? have tried doing that and its not working perphaps you could explain how I could use it in this line of my script.

Code: [Select]Set objFile = objFSO.OpenTextFile(C:\Scripts\CustomReport.xml", ForReading)

Code: [Select]Set objFile = objFSO.OpenTextFile("%SYSTEMDRIVE%\Scripts\CustomReport.xml", ForReading)
doesnt work.

thanks James.ok.

at the top of your script add:

Code: [Select]
Set wshell = CreateObject("WScript.Shell")
sysdrive = wshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")



and then when you need to use it:

Code: [Select]Set objFile = objFSO.OpenTextFile(sysdrive + "\Scripts\CustomReport.xml", ForReading)thanks that works great thats finished my script off nicely just one more thing if you dont mind, I've moved onto trying to make an installer now and having a little difficulty creating some shortcuts, the script is a batch file that CREATES a directory in user documents for later use by the program it creates a directory in program files and copies the scripts for the program to that location and creates a folder in the start menu for some shortcuts. everything works except for the creation of the shortcuts would you happen to know why? script is below.

Code: [Select]ECHO off
MD "%SystemDrive%\Program Files\MyMoviesReports"
copy "%~dp0\Uninstall.bat" "%SystemDrive%\Program Files\MyMoviesReports\"
copy "%~dp0\CreateCustomReport.vbs" "%SystemDrive%\Program Files\MyMoviesReports\"
copy "%~dp0\CreateCustomReport.bat" "%SystemDrive%\Program Files\MyMoviesReports\"
MD "%userprofile%\start menu\programs\MyMoviesReports"
MD "%userprofile%\MyMovieReports"
SHORTCUT -f -t "%SystemDrive%\Program Files\MyMoviesReports\CreateCustomReport.bat" -n "%userprofile%\start menu\programs\MyMoviesReports\CreateCustomReport"
SHORTCUT -f -t "%SystemDrive%\Program Files\MyMoviesReports\Uninstall.bat"

1976.

Solve : THREE BIG QUESTIONS?

Answer»

I'm back!!!
1. How can I create a randomized number with parameters.
2. Are there functions in batch? If so, how can I make them?
3. The loop command, how exactly does it work (examples please).
Quote from: tommyroyall on March 16, 2010, 11:54:38 AM

3. The loop command, how exactly does it work (examples please).

There is a for loop and a goto loop.  The loops RETURN to a previous line of code and REPEATS the same lines of code with a DIFFERENT index value.

Example:

Code: [Select]echo off
setlocal enabledelayedexpansion
for /L %%i in (1,1,1000) do (

set /p variable=Enter:
echo variable = !variable!
echo To Quit, Enter: q
if !variable!==q  goto  end
)
:end
echo ByeOutput:

C:\batch> nevertest.bat
Enter:one
variable = one
To Quit, Enter: q
Enter:two
variable = two
To Quit, Enter: q
Enter:7
variable = 7
To Quit, Enter: q
Enter:q
variable = q
To Quit, Enter: q
Bye

C:\batch>2. functions Quote from: tommyroyall on March 16, 2010, 11:54:38 AM
1. How can I create a randomized number with parameters.


C:\batch>TYPE  ran.bat
Code: [Select]echo off
:ran
echo random  =  %random%
echo To quit enter q or c to continue
set /p quit=Enter:
if %quit%==q goto end
goto ran
:end
Output:

C:\batch> ran.bat
random  =  29071
To quit enter q or c to continue
Enter:c
random  =  18757
To quit enter q or c to continue
Enter:c
random  =  6542
To quit enter q or c to continue
Enter:c
random  =  3041
To quit enter q or c to continue
Enter:c
random  =  3856
To quit enter q or c to continue
Enter:c
random  =  11257
To quit enter q or c to continue
Enter:q

C:\batch>

reference:

http://www.mathworks.com/access/helpdesk/help/toolbox/simevents/gs/a1076612075b1.html
Quote from: tommyroyall on March 16, 2010, 11:54:38 AM
1. How can I create a randomized number with parameters.


Code: [Select]echo off

setLocal EnableDelayedExpansion

for /L %%i in (1,1,%1 ) do echo random = !random!
Output:

C:\batch> ran2.bat  10
random = 5753
random = 1393
random = 5122
random = 16528
random = 12823
random = 14365
random = 5550
random = 28604
random = 1085
random = 11756
C:\batch>
1977.

Solve : How pickup registry key values from command prompt?

Answer»

Hi Guys,

I want to puckup the values of registry key i.e. [HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Contacts\Address Book\] with a name=path abd the value of it is C:\LOG;

Here i am trying to collect the above path(C:\LOG) availble  in batch file & want to use it as input to other command.

Note:  I have Microsoft Windows 2000 [VERSION 5.00.2195]

Can any one help in this case me in this case... Code: [Select]REG query "hklm\software\clients\contacts\address book" /V Path

You will get back 3 chunks of DATA: Name, Type and Value. You can use the for command to parse them.

Check out reg query /? from the command LINE for details.

Good luck.

1978.

Solve : Some more questions.?

Answer»

1. How would you rig a batch file up to a SERVER?
2. How exactly could you make it multiplayer, with a read write thing? I don't understand that. Please explain.
3. Boolean, can that be done with batch MAYBE using a special command or something?
4. Countdowns and timers, like if I wanted the program to maybe echo "Hi!" for 15 seconds, what would I do?MORE:
1. How could I pick the line out of a .txt document, like maybe the 5th line of a document called "document.txt"?
2. Are there objects in batch, and how exactly can I work them?2b. Maybe someone could try to immitate objects in DOS. I dunno.3. Boolean can perhaps be done with if and 1 and 0 or "true"/"false" string vars.

set a="true"
if a=="true" do xyz

4. What do you mean? Displaying "Hi!" for 15 seconds and then closing the file down or cls, or? Quote from: Treval on March 16, 2010, 12:36:36 PM

2b. Maybe someone could try to immitate objects in DOS. I dunno.

I don't think so. the LANGUAGE almost always has to have support for objects itself; this cannot be added on later; additionally, in order to properly emulate "objects" in batch you would need to have pointers, as well as structures, neither of which are available in batch.

Anyway- if you are trying to create objects in batch or think you need to you probably need a better tool; VBScript and JScript are built into Windows installations by default, and you can also get Perl, Python, and various other languages that fully support objects.

Quote from: Treval on March 16, 2010, 12:38:12 PM
3. Boolean can perhaps be done with if and 1 and 0 or "true"/"false" string vars.

set a="true"
if a=="true" do xyz

Ahh! but they are not true booleans- I think, the OP is explicitly referring to performing boolean arithmetic on them, with or and and and so forth. For example- in most languages flipping a boolean is easy, like:

Code: [Select]c=!c

but- with batch it has to be something like
Code: [Select]if a=="true" set a="false"
if a=="false" set a="true"

of course you could always try to make this easier with subroutines for the various boolean operations.


most of these questions come from treating the command batch language as a full-featured programming language; it WORKS fine at the PROMPT and for batches of commands, as it was designed, but if your batch needs any semi-modern language constructs (such as "objects") then what you are doing is too complex for batch (or your design is too complicated)


1979.

Solve : Parallels and LPT problem?

Answer»

Hi!

I solved problem with HDD in Parallels VM with MS-DOS 6.22, but I need to access LPT PORT too.

LPT port is CONFIGURED with IRQ and Legacy emulation. But it's LPT port on PCI card...
After start VM it reports to me an error that LPT is used by another process or I have no privileges to access and VM starts with disconnected LPT.

Here's my Q:
How to FIND (if) process which can using LPT? No application is running with this port.
How to set most privileges to LPT access (if)?

In ATTACHMENT is error message.

Thanks for every reply.

Miro

[Saving space, attachment deleted by admin]

1980.

Solve : 2 question: for loop and accented letters?

Answer» HELLO evryone,
this is KiTiK, i'm new here. And I'm new in batch scripting.
I read how for loop works both typing for /? in dos and in the article on this site.
But I still have some problem to get it entirely.
My purpose is to check if the COMMAND tasklist exist, and to do it i wrote this code:
Code: [Select]for /f "tokens=1,* delims=;" %%a in ("%PATH%") do (
if exist %%a\tasklist.exe (echo there is) else (echo there is not)
)this is good if the first entry in %path% is the system32 folder but i would like to check also in the other entries, but i connot understand how to do it without knowing the number of entries. Could you help me to understand it? It's puzzleing me

Another simple question: how can my bat echo accented letters (è, ò, ù) properly? I didn't find a solution searching in GOOGLE.
Thanks in advance and sorry for my bad English
Quote
this is good if the first entry in %path% is the system32 folder but i would like to check also in the other entries, but i connot understand how to do it without knowing the number of entries.

The is no need to know the number of entries in the path. You can use the $Path notation which will search the entire path until a match is found:

Code: [Select]echo off
for %%a in (tasklist.exe) do if not "%%~$PATH:a"=="" echo %%~$PATH:a
)

$Path will only search until a match is found. If you have multiple copies of a program, the snippet will echo only the first to the console.

Quote
Another simple question: how can my bat echo accented letters (è, ò, ù) properly? I didn't find a solution searching in google.

Not to familiar with this, but I think you can use  the chcp command.

Good luck.  really nice! I thought I should use $Path, but I put it in the wrong place, after the "IN".
Thanks, even if I'd like to ask you some explanation about the for loop, I use it in C programming, but it seems so different... I can not get it's logic, could you tell me something about it, please?

About the second question I think I'll use this notation: e', o', u' Quote from: SIDEWINDER on March 12, 2010, 08:57:33 AM

$Path will only search until a match is found. If you have multiple copies of a program, the snippet will echo only the first to the console.

Not to familiar with this, but I think you can use  the chcp command.

Good luck. 

To echo accented characters the command ENVIRONMENT needs to be using a "codepage" which has them in its character set. For the characters which you find in French and Spanish I use code page 1252 which you can select by

chcp 1252

at the prompt.

The code page you are currently in can be seen by typing chcp without a number.


Thanks for the tip Salmon Trout, but I tried it and I still get this symbol: þ instead of è.
Perhaps I have to specify something else in the echo command, but what?
Anyway thank you very much Quote from: KiTiK on March 12, 2010, 02:13:36 PM
Thanks for the tip Salmon Trout, but I tried it and I still get this symbol: þ instead of è.
Perhaps I have to specify something else in the echo command, but what?
Anyway thank you very much

what do you see when you type chcp at the prompt?

before i used chcp 1252 it was 850There's a different solution to what sidewinder is getting at, without changing any settings.

Open up MS-Word, put in your special characters, and click file > save. In the save menu, select Plain Text format (the one that says .txt). Then make sure the encoding is set to MS-DOS. If any letters are red, then they can't be used that way. Quote from: Helpmeh on March 12, 2010, 03:42:16 PM
There's a different solution to what sidewinder is getting at, without changing any settings.

Open up MS-Word, put in your special characters, and click file > save. In the save menu, select Plain Text format (the one that says .txt). Then make sure the encoding is set to MS-DOS. If any letters are red, then they can't be used that way.
Thanks Helpmeh, I did it and I noticed that mu special characters changes after I saved in that way. So, I guess, this is the problem. I wonder how and why the same special characters are well echoed for example in the for /? command... Is there a way to print characters with their ascii code, perhaps? I don't know. If this is possible this could solve another my problem I didn't speak about yet
Anyway, thanks for helping meI was able to paste è,ò, and ù into command prompt without changing anything... Quote from: BC_Programmer on March 16, 2010, 09:04:14 AM
I was able to paste è,ò, and ù into command prompt without changing anything...

Code: [Select]C:\Windows\system32>chcp
Active code page: 850

C:\Windows\system32>echo Nuages en début de journée
Nuages en début de journée
1981.

Solve : Please help, Square character at the end of file?

Answer»

Hello everyone, thank you for your attention.
I am processing multiple text FILES, in this CASE what I need to do is to copy content from one file "ALPHA*.txt" to multiple "*.DCC" files, without changing their names.

For exemple, I have source folder "a" with files "ALPHA*.txt"
and a folder "b" with multiple files with a "*.dcc" extension.

Here is my script:
------------------------------------------------------------------------
for %%f in (b\*.dcc) do copy a\ALPHA*.txt %%f
------------------------------------------------------------------------

It works, but the big problem is that it leaves a square character at the end of PROCESSED files.
And *.dcc files are used by another program that can not aceept this.

Please help me find a way around it.

Impacttry the /b SWITCH on the copy command.Well good sir, you saved my day!

I never thought there was so much to the copy command. 

Thank you!

 

1982.

Solve : Using short filename to change directory?

Answer»

Hello to everyone,
                             I work for a small, but always busy, computer repair shop.  I've been into writing batch files to automate things for years.  I'm in the process of writing a batch file that automates the 'manual system restore' process by allowing you to just enter the drive letter that you're dealing with, the user account name, the restore point that you want and the program will do all of the copying, moving, renaming etc...  The problem I'm having is that I can enter the following from the C:\> "CD System~1", and it will put me in the "System Volume Information" directory, but upon entering the exact same command from the 2nd hard drive E:\> prompt, I get, "The system cannot find the path specified".  I can type  CD "System Volume Information", and it will work that way, but the next directory that I need to go into without having to type the full name because it's VERY long, is the "_restore{LooooooooooooooooooDirectoryName.....................} directory.  This directory name is different inside the brackets from one computer to the next so it can't be used in the program as a constant.  Again, from the C:\System~1> directory, I can enter "CD _resto~1", and be in the C:\System~1\_resto~1> directory, but the same doesn't apply from the E:\> prompt, and I just keep getting, "The system cannot find the specified path".  I'm running XP Pro on a Dell Dimension 4550, and the 2nd hard drive, Drive E: has XP pro on it as well.  I've gone into the 'Sharing and security'  and made the directories that I'm dealing with accessible.  I just don't understand what what works on C:\> doesn't work on E:\>...Thanks, in advance, for any attempt at resolving this, and have a good one,

Michael I'm having a hard time wrapping my single LIVING brain cell around your request.

Quote

The problem I'm having is that I can enter the following from the C:\> "CD System~1", and it will put me in the "System Volume Information" directory, but upon entering the exact same command from the 2nd hard drive E:\> prompt, I get, "The system cannot find the path specified".  I can type  CD "System Volume Information", and it will work that way

Normally, the system and hidden attribute bits are turned on for the System Volume Information directory. If I try your command I get "access denied" I'm not sure mucking around in this directory is a good thing and in any case I doubt there is anything batch code can do with the files/data in the directory.

Quote
I'm in the process of writing a batch file that automates the 'manual system restore' process by allowing you to just enter the drive letter that you're dealing with, the user account name, the restore point that you want

Restore points are numbered. You can restore a system by referencing that number. System restore will restore all the drives/partitions that are currently being monitored. As far as I know you cannot pick and choose drive letters, it's either all or nothing. For that you would need a backup/restore application such as NTBackup (installed with XP Pro; install from XP CD on XP Home)

You can check out these VBScripts. You will need the "Viewing All Existing Restore Points" script to get the number of the restore point, and the "Conducting a System Restore" script for actually doing a restore.

Truthfully I can't see much improvement over the Microsoft System Restore GUI. Seems like you're reinventing the wheel.

Good luck.  Thanks, Sidewinder, for taking the time to respond.  I do appreciate it  .  I'm not, however, TRYING to reinvent anything.  If you were to google "Manual System

Restore" you'd probably see in there somewhere what I'm trying to write a batch-file for.  The process is as follows: 

1) Connect the drive that you need to manually restore to a computer as a 2nd hard drive (I've been using a USB hot-swapable cable to connect the drive to the system).


2) Make sure 'Show hidden files and FOLDERS' is selected, and 'Hide extensions for known file types' is unchecked by clicking 'My Computer\Tools\Folder Options\View'

3) Navigate to the following directory of the drive that you've just connected (in this case we'll say it's drive (E:) ) 'E:\WINDOWS\system32\config'

4) Right-click the desktop and select 'New' then 'Folder' and name it 'TMP' or something you'll remember and open the folder.

5) There will be 5 files without any extensions at all.  Just what you see between the single quotes, 'Default', 'Software', 'System', 'SECURITY' and 'SAM'.  Hold down

the CTRL key and click each of these files then right-click one of them and drag them into the new folder that you just made on the desktop and choose 'move'

6) In 'My Computer', Open 'Local Disk (C:) and scroll down to 'System Volume Information', Right-Click and select 'Sharing and Security...', then click 'Security' click 'Add' and enter your user account name in the box and click 'Ok'

7) Check the box next to 'Full Control' and click 'Ok'.  Open 'System Volume Information', and then '_restore{52D47666-AC67-41BB-8E40-C4A9FA6443A1}' (the letter-number combination differs from one drive to the next).

<--(That was supposed to be an '8') Now you get to choose your restore  point (as you pointed out, they're numbered...They're also dated if you enable 'details' from the 'view' drop-down box on the folder menu over the address box).

9) Once you've picked your restore point, there's another folder in here called, 'Snapshot'.  Open the 'Snapshot' folder.

10) Inside the 'Snapshot' folder there are 5 files that begin with, '_REGISTRY_MACHINE_', and end with the same 5 file names as in step 5 (the only difference being that there's a '.' before 'DEFAULT') , so hold down the CTRL key, just as in step 5, and click '_REGISTRY_MACHINE_.DEFAULT', '_REGISTRY_MACHINE_SOFTWARE', '_REGISTRY_MACHINE_SECURITY', '_REGISTRY_MACHINE_SYSTEM' and '_REGISTRY_MACHINE_SAM'.  Right-click one of them and select, 'Copy'.

11) Navigate to 'E:\WINDOWS\system32\config' and right-click and paste the files.  This is the same directory that you moved the files from step 5 out of.

12) Right-click each of the FIVE files and select, 'rename'.  Remove everything from the name except for the very last part of the name before the last underscore ('_'), so '_REGISTRY_MACHINE_.DEFAULT' becomes, 'DEFAULT' , '_REGISTRY_MACHINE_SOFTWARE' becomes, 'SOFTWARE' and so on for the other 3.


And that's it.  You've just manually restored your computer.  This can be useful when some really nasty virus disables your 'System Restore' functionality, and you can't get to the usual way of doing it from the 'Start\Programs\Accessories\System tools\System Restore'   Sure hope this is useful to someone. 

Oh, I almost forgot, A good friend figured out my original dilema.  All you need to do is enter the following...'CD Sy*' will put you into the 'System Volume Information' directory, and then, 'CD _*' will put you into the '_restore{52D47666-AC67-41BB-8E40-C4A9FA6443A1}' directory.Hi All,
         This is a CORRECTION update to my last post.  In step 6, the 'Local Disk (C:)' should have been, 'Local Disk (E:).  I'm sorry for any confusion,

Michael
1983.

Solve : change text in XML files?

Answer»

that little batch snippet i wrote is all you need to change all xml files under the directory passed using sed. what more is it you require? in fact , i added the for loop only for doing recursive searching, otherwise if your xml files are all in one directory, then  this is all you need.
Code: [Select]sed -i.bak "s/old/new/g" *.xml
Actually, from the looks of that code, it will take all the .xml files from a directory and perform the word switch for each. (But I don't have sed, so ghostdog will need to confirm my thoughts) Quote from: Helpmeh on March 24, 2010, 06:37:01 AM

Actually, from the looks of that code, it will take all the .xml files from a directory and perform the word switch for each. (But I don't have sed, so ghostdog will need to confirm my thoughts)
see reply 15 Quote from: ghostdog74 on March 24, 2010, 06:38:52 AM
see reply 15
Sorry, you must have GOTTEN in right before me, lol... Quote from: ghostdog74 on March 24, 2010, 06:36:22 AM
Code: [Select]sed -i.bak "s/old/new/g" *.xml


The above sed does not work. The original xml file remains the same

Example:

C:\batch>type ghost24.bat
Code: [Select]echo off
Rem The sed change is displayed to the screen only
rem The original xml remains unchanged
echo type envmig.xml
type  envmig.xml

sed  "s/newfile.xml/new/g" envmig.xml

echo type envmig.xml
type  envmig.xml
Output:

C:\batch>ghost24.bat
type envmig.xml
newfile.xml
new
type envmig.xml
newfile.xml
C:\batch>it remains unchanged because you did not redirect to a new file or use -i.
sed by default doesn't change files.
please look at my code again and compare it to yours. Its totally different. Why do you produce different code and say it does not work. ? Quote from: ghostdog74 on March 24, 2010, 09:56:40 AM
it remains unchanged because you did not redirect to a new file or use -i.
sed by default doesn't change files.
please look at my code again and compare it to yours. Its totally different. Why do you produce different code and say it does not work. ?

Ghost,

Thanks for your help.

I must have a different version of sed than you do.

I cannot get my sed to work with your code.


C:\batch>sed -i.bak "s/HKCU/new/g" envmig.xml
Unknown OPTION "-i.bak"
Usage: sed [-nE] [script] [-e script] [-f scriptfile] [file ...]

C:\batch>

______________________________


C:\batch>type   envmig.xml  |  more
http://www.microsoft.com/migration/1.0/migxmlext/oobeupgrade">

 
    oobeUpgrade
   
      %WINDIR%\oobeUpgrade
   
   

     
       
         
            MigXmlHelper.IsOSLaterThan("NT","6.0.0.0")

         
       
       
         
           
              MigXmlHelper.DoesObjectExist("REGISTRY",
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders [My
Music]")
           
           
              MigXmlHelper.IsSameStringContent...
.
.
.why are you using crippled sed?? see reply 13 on where to download GNU sed.  All my *nix tools are from GNU, not mks. and its free.. Quote from: ghostdog74 on March 24, 2010, 11:44:09 AM
why are you using crippled sed?? see reply 13 on where to download GNU sed.  All my *nix tools are from GNU, not mks. and its free..

Please show me the output for your sed.

sed -i.bak "s/old/new/g" *.xml
it doesn't take 5 minutes to download and try it out yourself. Quote from: ghostdog74 on March 24, 2010, 11:54:30 AM
It doesn't take 5 minutes to download and try it out yourself.

The gnu sed did work:
sed -i.bak "s/HKCU/new/g" envmig.xml

The redirection is implicit with -i.bak.  envmig.xml.bak is created in the same directory.  Then envmig.xml.bak  is copied over envmig.xml.  The changes to envmig.xml appear to occur in place.

One line of sed code to replace the long batch file above.

Command line arguments could be used for "old" and "new".  Then the sed
code sed -i.bak "s/old/new/g" would not need to be changed each time.

Output:

C:\batch>c:\bin\sed -i.bak "s/HKCU/new/g" envmig.xml


C:\batch>type  envmig.xml  | more
http://www.microsoft.com/migration/1.0/migxmlext/oobeupgrade">

 
    oobeUpgrade
   
      %WINDIR%\oobeUpgrade
   
   

     
       
         
            MigXmlHelper.IsOSLaterThan("NT","6.0.0.0")

         
       
       
         
           
              MigXmlHelper.DoesObjectExist("Registry",
"new\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders [My M
usic]")
           
           

Input:

C:\batch>type  envmig.xml |  more
http://www.microsoft.com/migration/1.0/migxmlext/oobeupgrade">

 
    oobeUpgrade
   
      %WINDIR%\oobeUpgrade
   
   

     
       
         
            MigXmlHelper.IsOSLaterThan("NT","6.0.0.0")

         
       
       
         
           
              MigXmlHelper.DoesObjectExist("Registry",
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders [My
Music]")
           
           
              MigXmlHelper.IsSameStringContent Quote from: GREG on March 24, 2010, 02:47:23 PM
One line of sed code to replace the long batch file above.
EXACTLY! Ghost said that a the top of the page in reply #15! Quote from: Helpmeh on March 24, 2010, 06:37:01 AM
Actually, from the looks of that code, it will take all the .xml files from a directory and perform the word switch for each. (But I don't have sed, so ghostdog will need to confirm my thoughts)

If Helpmeh does not have have sed then Helpmeh was unable to test the code. Helpmeh doesn't test the code or show output.

Helpmeh wrote: (post #26 )
"EXACTLY! Ghost said that a the top of the page in reply #15!"
1984.

Solve : Dos Dir CMD to send info to a txt file??

Answer»

Running Win XP Pro.

I need to make a TEXT file containing a list of all files and DIRECTORIES on a DVD.

Run:  CMD
Change to drive E:
E:\>dir  /s /w /O:ND         This desplays the list of directories and files I need in the correct order.

What I now need to do is have it SAVE this list in a file on Drive C so I can email it. I've tried both cmds below and neither worked. What am I doing wrong?

E:\>dir  /s /w /O:ND> C:\myphotos.txt
E:\>dir> C:\myphotos.txt  /s /w /O:NDI finally figured out how to redirect the output of the DVD directories to a file.

Start/Run/ CMD
At the dos prompt dir E:\ /s /g /O:NG > C:\myphotos.txt

1985.

Solve : Batch Delete Files And Folders?

Answer»

I Seriously Need Help My Friends ! I Am Making Dos Setup For Some Portable Programs

I Want A Batch To Do The Foll Things -

1] It Is In .\Other Folder But Should Be Exectued From "temp" Folder (Basically This Work Could Be Done By WRAR , But Still If Another Steps)


2] After EXECUTION It Should Delete The Files.ext And Folders In .\Other Folder.


3] Lastly It Should Delete Itself And The .\Other Directory. Quote from: the_mad_joker on March 27, 2010, 10:41:42 AM

1] It Is In .\Other Folder But Should Be Exectued From "temp" Folder (Basically This Work Could Be Done By WRAR , But Still If Another Steps)

2] After Execution It Should Delete The Files.ext And Folders In .\Other Folder.

3] Lastly It Should Delete Itself And The .\Other Directory.


C:\batch>type joke27.bat
Code: [Select]echo off
cd \
md other
cd other
echo HELLO joker > joker27.txt
md other2
cd other2
echo hello joker > joker28.txt

cd \
cd other
Type  joker27.txt
cd other2
type joker28.txt
cd \
cd other
cd other2
del /Q *.*
cd ..
rd other2
cd \
del /Q  c:\other\*.*
rd other

rem MV c:\batch\joke27.bat  c:\temp\
rem del c:\temp\joke27.bat
Output:
C:\batch>joke27.bat
hello joker
hello joker

C:\>THANKS Dude !!!!!
1986.

Solve : Found cmos battery?

Answer»

I finally found the BATTERY for my computer ! It's soldered in. Does anyone know where I can find one these? Can it be replaced 
:see attachment         
   
              RLvideo                                                 

[Saving space, attachment deleted by admin]Thats work for a repair shop...too much heat in the wrong spot = dead MBoard...SomeOne said If I would leave the computer plugged in & turn on for over 24 hrs. it would recharge it self ? It's this TRUE?
                                       Thanks  for the Help!!
                                            RLvideoNo.Would it be cheaper to put in a new mother BOARD?Depends on what the shop says...
If it's that old i'd shop for a board...but what are your goals for this machine and what would the budget be ? ?WOW... this is really weird.

I was going to say something along the lines of "sometimes is actually on a chip called a "Dallas Clock chip" but as far as I know those are only on REALLY REALLY old PCs... Early AT MODELS.

Judging by the picture, the motherboard is also using a P8/P9 connector... so it is an older model... but I didn't think it was that old; or maybe Dallas Clock chips are in models newer then I was aware.They had a 10-year lifetime, which seemed enough, at the time.  Sockets were too expensive and deemed unncecessary.  Dallas is now OWNED by Maxim who still produces replacements for about $10.  Read this first:  http://www.maxim-ic.com/app-notes/index.mvp/id/503

1987.

Solve : Execute files using a batch?

Answer»

I am trying to make a BATCH file so that i can easily start one of the many programs i have, without spamming my desktop with icons. I can get the menu and everything down, but i am having problems with executing them. I have tried USING CALL and just entering the file name after setting the directory. The programs start, but the batch file does not continue until after I close the program. It just sits there waiting. How would i set it to start it, and continue without waiting?I have not tried to code the process but here are a few ideas.

1) Have the menu ( main batch ) call the sub batch
2) Have the sub batch put the program in the background with the at command
3) The background process must redirect standard out and standard error to a file or  the sub batch will open a screen and interfere with your new  tasks.

I will give it a shot.

In the meantime post your menu. Quote

1) Have the menu ( main batch ) call the sub batch
                                            ^
                                            ^

                                Could Be The Best option

For EXAMPLE

Code: [Select]echo off
color 0c
echo.
echo   Pls Wait Executing Applications....
echo.
FIRSTFILE.exe
cls
echo.
echo   Pls Wait Executing 2nd Application
echo.
SECONDFILE.exe
cls
rem And So On The File Names
echo.
echo   Done!
echo.
pauseI've already tried something like that, but the secondary batch just pauses and sits there ALSO. I have to close the program before the secondary batch continues, and the secondary has to finish before the first continues.Try using the start cmd (type start /? at the cmd prompt for more info)

Code: [Select].
.
echo.
echo   Pls Wait Executing Applications....
echo.
start "" FIRSTFILE.exe
cls
echo.
echo   Pls Wait Executing 2nd Application
echo.
start "" SECONDFILE.exe
.
.
THANK you very much, that last one worked
1988.

Solve : recursive search for the lowest level folder?

Answer»

Hello,
I need help from your part,
I have to find the lowest LEVEL folder in a folder structure and INSERT a delete_me.txt in that level
how to I recursevly search for the lowest level? and insert ofcourse this delete_me.txt fileyou should show an example of what you are trying to do. lowest level of directory structure is :\ ie c:\ , d:\ etc.. Quote from: mibushk on March 29, 2010, 02:24:49 AM

I have to find the lowest level folder in a folder structure and insert a delete_me.txt in that level
how to I recursevly search for the lowest level? and insert ofcourse this delete_me.txt file


C:\BATCH>dir /s  delete_me.txt
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\batch\lower\lower

03/29/2010  07:11 AM                10 delete_me.txt
               1 File(s)             10 bytes

     Total FILES Listed:
               1 File(s)             10 bytes
               0 Dir(s)  296,553,267,200 bytes free

C:\batch>cd lower

C:\batch\lower>tree /f
Folder PATH listing
Volume serial number is F4A3-D6B3
C:.
└───lower
        delete_me.txt


C:\batch\lower>cd lower

C:\batch\lower\lower>dir
 Volume in drive C has no label.
 Volume Serial Number is F4A3-D6B3

 Directory of C:\batch\lower\lower

03/29/2010  07:11 AM              .
03/29/2010  07:11 AM              ..
03/29/2010  07:11 AM                10 delete_me.txt
               1 File(s)             10 bytes
               2 Dir(s)  296,553,267,200 bytes free

C:\batch\lower\lower>C:\01Project
C:\02Development
C:\02Development\01 Documentation

I have to introduce a delete_me.txt file in 01Project and in 01Documentation


Quote from: mibushk on March 29, 2010, 06:59:42 AM
C:\01Project
C:\02Development
C:\02Development\01 Documentation

I have to introduce a delete_me.txt file in 01Project and in 01Documentation


cd \
md  01Project
copy delete_me.txt  C:\01Project\

md  02Development
cd 02Development
md  01 Documentation
cd \
copy delete_me.txt  "C:\02Development\01 Documentation\"

Quote from: greg on March 29, 2010, 11:49:23 AM
whatever

1989.

Solve : Java for DOS?

Answer»

Bah BC, I've programmed in java for 3 years and you still know more of java than me. =P MEH!

ANYWAYS..
BC is right, java is a Windows program (not only windows, it's cross-platform! However I wonder if it's cross-platform-DOS-compatible.. since DOS is part of a platform.. but a supported one?.. java was first designed for to work on microcontrollers of microwave's/washing machines/etc..). DOS is an old OS. This means it runs in 16-bit unprotected MODE and Windows runs in 32-bit protected mode. They can't 'see' each other. Or something like that. I forgot the details. =P
Anyway DOS was a seperate OS by itself (as it says, Disk Operating System). Windows is a seperate OS by itself.

My suggestion is to run this in Windows or.. I don't know.. emulate it in a VM?... =P

Treval
Quote from: Treval on March 30, 2010, 05:44:31 AM

Bah BC, I've programmed in java for 3 years and you still know more of java than me. =P MEH!



Quote
java was first designed for to work on microcontrollers of microwave's/washing machines/etc..
Actually, by the time it had the name java they were aware that it was going to be deployed as a more general purpose language that ran on a VM; when they actually wanted to run it in coffee machines and other stuff as an "appliance language" or something it was still called "oak".



Well, the only downloads you can find from sun will be for the win32 version of the VM; win32 requires... well, win32. (windows 95 and higher) Of course later versions of the windows VM are SPECIFICALLY written to use NT specific stuff so they don't work on win9x, either.

The "best" windows 3.1 VM available is an ancient IBM release. It's the best available but it is still awful. Since it wasn't defined that you could run a "jar" archive directly until fairly recently you'd need to extract all the class files from it too... which would introduce loads more problems due to 8.3 filenames... and then you have to edit some weird file that tells the java system which 8.3 files map to what long file names. it's horrible.

A DOS implementation of the VM is nearly impossible- best case scenario would SIMPLY be totally awful. the VM itself would need to emulate threads (it did in the win31 version, but it usually crashed)... messy, messy business.

For windows 95, I'm not sure of the version that would work but you're probably looking at JDK 1.0 or 1.1, if you are really really lucky 1.5, or 2.0. but I doubt it. The best VM you can get for windows 95 is probably the Microsoft JVM, problem being that you can't get that anywhere now.

If you have some old software discs, sometimes it came included with it. I know Visual Studio 6 has the MSJVM on it's CD; It's probably the same for any number of other applications, most notably Internet Explorer.

Even so, that's just the VM... getting the SDK itself is another gambit altogether.

I did a google and I found this:

http://java.sun.com/j2se/1.3/install-windows.html

Quote
The Java 2 SDK is intended for use on Microsoft Windows 95, 98 (1st or 2nd edition), NT 4.0 with Service Pack 5, ME, 2000 Professional, 2000 Server, 2000 Advanced Server, or XP operating systems running on Intel hardware.

is says it works on windows 95





[/quote]
1990.

Solve : Problem With VBS script?

Answer»

i made a script like
Code: [Select]rc = MsgBox("TU Esi Ilze?", vbYesNo, "Tu Esi Ilze")
If rc = 6 Then WScript.Echo "Stulbene"
End if
if rc = 7 then rc = MsgBox("Tevi sauc Laura?", vbYesNo, "Tevi sauc Laura")
If rc = 6 Then WScript.Echo "Stulbene"
End if
If rc = 7 Then rc = MsgBox("Tevi Sauc Samanta?", vbYesNo, "Tevi Sauc Samanta")
If rc = 6 Then WScript.Echo "Stulbene"
End if
If rc = 7 Then rc = MsgBox("Tevi Sauc Gabriela?", vbYesNo, "Tevi Sauc Gabriela")
If rc = 6 Then WScript.Echo "Stulbene"
End if
If rc = 7 Then rc = MsgBox("Tevi Sauc Svens?", vbYesNo, "Tevi Sauc Svens")
If rc = 6 Then WScript.Echo "Krutais !"
If rc = 7 Then WScript.Echo "KURAA DIRSAA TAD ES ESU IEMALDIJIES ?"
End if
but it SENDS me an error
i wanted so if the answer to the question is yes the she will have no questions
if answer is no then go to next questionYou need to review the rules about

IF  ... THEN ... END IF

http://www.tizag.com/vbscriptTutorial/vbscriptif.phpWhen you start tripping over your own code, it's time for another approach 

Code: [Select]arrQuestion = Array("Tu Esi Ilze?", "Tevi sauc Laura?", "Tevi Sauc Samanta?", "Tevi Sauc Gabriela?", "Tevi Sauc Svens?")

For i = 0 To UBound(arrQuestion)
rc = MsgBox(arrQuestion(i), vbYesNo, arrQuestion(i))
If rc = 6 Then
WScript.Echo "Stulbene"
EXIT For
End If
Next

If i = UBound(arrQuestion) + 1 Then
If rc = 6 Then WScript.Echo "Krutais !"
If rc = 7 Then WScript.Echo "KURAA DIRSAA TAD ES ESU IEMALDIJIES ?"
End If

As with your previous post, save the snippet with a vbs extension and run from the command prompt as CSCRIPT scriptname.vbs

Good LUCK.

1991.

Solve : delete program?

Answer»

I'm using this program to delete stuff but it doesn't delete folders how can i make it delete folders
Code: [Select]echo off
echo y | del %1
echo the file %1 was deleted
pause
del removes files; RD removes directories (folders), but they have to be empty first.
how can the program cheak if its a folder or file
This should work on an XP machine. The RD command will only delete empty directories unless you use switches to override the default. Not recommended. You may delete more than you bargained for.

Code: [Select]echo off
if exist %1\nul (rd %1) else (echo y | del %1)

This is batch code, so SAVE the SNIPPET with a bat extension and run from the command prompt as scriptname.bat

The code expects a file or directory name to be passed on the command line.

Good luck.  sorry sidewinder that dosent work
this does though but THANKS for your help
Code: [Select]echo off
if exist %1/.. goto fol > nul
echo y | del %1
goto :eof

:fol
echo y | del %1
echo y | rd %1
that'a exactly what sidewinder posted, but your checking for .. instead of nul, and you used the wrong slash (the forward slash (/) is used for web ADDRESSES and UNC paths (and Linux pathnames). the backslash (\) is used as a path separator on windows systems. Most file accesses can be done with both since they convert forward slashes to backslashes as appropriate, but bear in mind that the  "natural" path separator is \.

this is functionally identical to your "changed" version:

Code: [Select]if exist %1\nul (echo y | rd %1) else (echo y | del %1)

I can't think of any reason you'd need to but you can change nul to . or ..

Your version makes no sense... if you detect it's a directory, you still use del on it. This has the effect of deleting the contents of the folder.

if you want the same ability with SideWinders script, you should read his comment re: switches. you can use the /s switch to make rd/rmdir remove a directory and all it's sub-directories in a single blow. if you use /q you won't even need to pipe a "y" response to it, either. so:

Code: [Select]Echo off
if exist %1\nul (rd %1 /s /q) else (echo y | del %1)
the only reason i said that he got it wrong was i didnt checck if it works using cmd i just draged the folder on top. I must have missed the part where you wanted drag and drop capabilities:

Code: [Select]echo off
:next   
   if exist %1\nul (echo y | rd %1) else (echo y | del %1)
   if .%2 equ . goto :eof
   shift
   goto next

When coding drag and drop, you should code for the situation where the user drags multiple files, folders or a combination of both.

Why not just drag and drop to the recycle bin? Not only do you logically remove the files and folders but you can easily restore them in case of the over enthusiastic user. With batch files or Windows scripts there is no provision for a pit stop in the recycle bin.

Good luck. Quote from: Sidewinder on March 30, 2010, 03:03:52 PM



Why not just drag and drop to the recycle bin? Not only do you logically remove the files and folders but you can easily restore them in case of the over enthusiastic user. With batch files or Windows scripts there is no provision for a pit stop in the recycle bin.


Additionally, if they want to permanently delete them, you can hold shift when you drop it on the recycle bin as well.
1992.

Solve : Batch Process, Folders, ICONs?

Answer»

I am using a batch process to push a folder to user desktop.  Also have an ICON that I would LIKE to post on that folder instead of the manila folder look.  Is there a series of DOS code steps that I can add to my BAT file that would set the preference of choosing a different ICON - the ICON that I've created? Quote from: Tulsastrategic on March 29, 2010, 05:10:13 PM

ICON that I would like to post on that folder instead of the manila folder look. 

http://malektips.com/xpwex0001.html


Tired of most folders looking like the same drab YELLOW open file? You can change a folder's icon in Windows XP to better signify its contents. To change a folder's icon:

1. Right-click on a folder and choose "Properties".

2. When the "Properties" multi-tabbed dialog box appears, select "Customize".

3. Click the "Change Icon" button.

4. Choose an icon you wish to use and click "OK", or click "Browse" to browse your system for other icons. Look for .ICO and .EXE files on your system for more icons. You may even want to download some freeware icons over the Internet.

5. Press "OK" to close the dialog box.

Note that you may need to close and reopen the folder for the icon change to take effect.

_____________________________

Drag and Drop

1) Open less than FULL screen  the folder that contains the folder to move to the desktop.
2) Point the the icon and hold the left button down and drag to the desktop and release.

Quote from: Tulsastrategic on March 29, 2010, 05:10:13 PM
I am using a batch process to push a folder to user desktop.  Also have an ICON that I would like to post on that folder instead of the manila folder look.  Is there a series of DOS code steps that I can add to my BAT file that would set the preference of choosing a different ICON - the ICON that I've created?

yep, you can create a desktop.ini file from WITHIN your batch file. if you copy an icon into the folder you can create a desktop.ini like this:

Code: [Select][.ShellClassInfo]
IconFile=icon.ico
IconIndex=0
Thank you for the quick response.  I had this code just after the MD command on separate lines.  It didn't post the ICON, though.  Does the ICON file need to be in the temp folder where the files land originally, or does the ICON file need to be in the final folder on the Desktop? Quote from: Tulsastrategic on March 30, 2010, 12:09:20 PM
Thank you for the quick response.  I had this code just after the MD command on separate lines.  It didn't post the ICON, though.  Does the ICON file need to be in the temp folder where the files land originally, or does the ICON file need to be in the final folder on the Desktop?
the icon needs to be in the folder you are giving the icon to.

Remember that stuff I posted was what you need in a desktop.ini file in that folder. it MIGHT also need to be hidden, I'm not sure.That's what I needed - thanks for the clarification.
1993.

Solve : count the number of files according to time modified?

Answer»

HELLO FRIENDS

i want to count number of files according to the date and then in between the time interval in the windows file system and save the out put in the text file
with details like this 

date                        time interval              count
=========================================

30/03/2010             0200-0400                 900
30/03/2010             0400-0600                 897
.................                  -------                           --
30/03/2010             2200-2400                 785

 


Waiting for Your replies

bye for now here's a Python script.

Code: [SELECT]IMPORT os
import time
results={}
path = os.path.join("c:\\","test")
output=os.path.join("c:\\","test","output.txt")
o=open(output,"w")
o.write("date\t\ttime_intervale\t\tcount\n")
for R,d,f in os.walk(path):
    for files in f:
        fpath=os.path.join(r,files)
        mtime = time.localtime(os.path.getmtime(fpath))
        file_date = time.strftime("%m/%d/%Y",mtime)
        file_time = int(time.strftime("%H%M",mtime))
        tag=""
        if file_time >= 200 and file_time <400:           
            tag="\t200-400"                       
        elif file_time >= 400 and file_time <600:
            tag="\t400-600"           
        elif file_time >= 800 and file_time <1000:
            tag="\t800-1000"
        elif file_time >= 1000 and file_time <1200:
            tag="\t1000-1200"
        elif file_time >= 1200 and file_time <1400:
            tag="\t1200-1400"
        elif file_time >= 1400 and file_time <1600:
            tag="\t1400-1600"           
        if tag:   
            results.setdefault(file_date+tag,0)       
            results[file_date+tag]+=1           

for key in sorted(results.keys()):
    print key,results[key]
    o.write(key + "\t"+str(results[key]) + "\n")
o.close()

save as myscript.py and on COMMAND line,
Code: [Select]c:\test> python myscript.py
add the rest of the time as needed

1994.

Solve : Inserting a Blank Space Before Set /P Output?

Answer»

Quote from: BC_Programmer on March 30, 2010, 07:18:06 AM

Sure Python/Perl have modules you can use for nearly everything; so does VBScript. It's called COM. and COM components are a lot easier to use from VBScript as compared to either Python or Perl
that is not true. If one really have extensive experience with Python/Perl, you will know there are too many things vbscript cannot compare. Find me a FTP module in vbscript that does file transfer, or secure file transfer(SSH). Or find me a good compression LIBRARY that supports widely used compression algorithm in vbscript. Data structures in Perl/Python are much easier to use than those in vbscript, and more flexible. How about a sorting function in vbscript? till now, i don't see very good support on sorting. And how about emailing mechanism or the ability to do network/socket programming easily? How about a library for HTML/XML parsing or a library to grab a web page that also supports proxy authentication or SSL?

Python/Perl already has extensive support for such things. COM? you might be surprised that Perl/Python supports COM as well.

How about portability of code? Python/Perl scripts WORKS in Mac,*nix. Is vbscript portable?

I use vbscript as well and i have no problem coding with it when the situation needs, but if i have a choice on language to use on a production project, it will not be vbscript Quote from: ghostdog74 on March 30, 2010, 08:12:54 AM
Find me a FTP module in vbscript that does file transfer, or secure file transfer(SSH).
http://www.chilkatsoft.com/FTP-ActiveX.asp

Quote
Or find me a good compression library that supports widely used compression algorithm in vbscript.
Google gives me 126,000 hits for "ActiveX Compression Library"

Quote
Data structures in Perl/Python are much easier to use than those in vbscript, and more flexible.
All accessible via COM... or just create them yourself in VBScript classes. Seriously, you write them once, and you can reuse them. there doesn't HAVE to be a bloody module for every single god damned thing you mgiht want to use.

Quote
How about a sorting function in vbscript? till now, i don't see very good support on sorting.
Again: a case of roll your own. Writing a sorting routine is easy. This hardly even counts.

Quote
And how about emailing mechanism or the ability to do network/socket programming easily?
CDO. WinSock Control/Library.
Quote
How about a library for HTML/XML parsing
MSXML.

Quote
or a library to grab a web page that also supports proxy authentication or SSL?
WinHTTP.

Quote
Python/Perl already has extensive support for such things. COM? you might be surprised that Perl/Python supports COM as well.

Did you even read my post?

Quote from: BC_Programming
and COM components are a lot easier to use from VBScript as compared to either Python or Perl (which in themselves need a module for this purpose)

Quote
How about portability of code? Python/Perl scripts works in Mac,*nix. Is vbscript portable?
Nope. Sometimes I forget how important that 0.5 percent (ok, that's an underrepresentation) of the market considers itself though.
Quote from: BC_Programmer on March 30, 2010, 08:40:39 AM
http://www.chilkatsoft.com/FTP-ActiveX.asp
I was betting you are going to show me this.
sad to say first version out of support and limited in functionality. 2nd version cost money. seriously ?

Quote
Google gives me 126,000 hits for "ActiveX Compression Library"
out of the 126000 hits, which one is free and you have used it to support zip, gzip and is highly recommended to be used in vbscript ? with Perl/Python, compression libraries comes with the distribution and most of the time, its the recommended one to use and is supported by the community.

Quote
Again: a case of roll your own. Writing a sorting routine is easy. This hardly even counts.
sorting stuff is so common in daily task, you don't  rewrite it when you want to use it every time . A good sorting library is a certainly a plus point. Try writing one by hand,  that sorts by a field, then another field, followed by another field, lastly, by another field but this time sort numerically. how much time would you need to do it with vbscript?

A module for every thing i want to do is even BETTER. honestly speaking, don't you sometimes want that?
Quote
sorting stuff is so common in daily task, you don't  rewrite it when you want to use it every time

No. you write it ONCE. and then you can that every time.

Quote
A good sorting library is a certainly a plus point. Try writing one by hand,  that sorts by a field, then another field, followed by another field, lastly, by another field but this time sort numerically.

Ever worked with listviews? Ever needed to do that as well as Natural sort the filename column? Yeah. done that. Actually, I didn't write the code  that does the sort algorithm, that is actually in comctl32.

My Actual Sorting stuff can be used to sort objects, and since the Actual comparison routine can easily be overridden it's a simple matter to change the comparison to make it sort on different fields. This wouldn't extend directly to VBScript since none of the scripting languages supports early-binding to COM components that I know of nor implementing a COM interface. I think they support event sinking so I could just make it raise events or something.

Either way, I never have to do anything with VBScript. I only have one Script file that I ever use, that re-links an executable to change the subsystem. That's it. I largely consider VBScript to be VB6 but to be frank VBScript blows in comparison. and I am reminded of that every time I use VBScript.

WHY does it complain when I say Next ? I could swear that's part of the language, but noooo, it makes me say just "next"...

Quote
I was betting you are going to show me this.
sad to say first version out of support and limited in functionality. 2nd version cost money. seriously ?


That was just from a quick google.

There are FTP controls built into windows but I'm not sure if those can be used without a IOLEInPlaceSite implementor. (that is... a window) I know the "Script control" can be used just as an Object.


Quote
out of the 126000 hits, which one is free and you have used it to support zip, gzip and is highly recommended to be used in vbscript ? with Perl/Python, compression libraries comes with the distribution and most of the time, its the recommended one to use and is supported by the community.

Personally I'd just Use BCFile for that. Of course I'd need to get BCFile to work in VBScript, a mystery I have yet to bother solving since I never use VBScript, or any other scripting language often enough.

Actually, I think I've lost track of the very point of a scripting language, which is, in general, to provide these types of things. unzipping and zipping can be done with the built in windows Zipping/unzipping but the mechanism for doing so isn't immediately obvious. It can be used indirectly by simply copying a file out of a zipped file namespace, but again- not completely obvious.

Anyway, I think this is what confused me:

Quote
but if i have a choice on language to use on a production project, it will not be vbscript

a scripting language shouldn't be used in a "production" project. a scripting language should be used for scripting. python can be used for applications programming but that is- get this, outside the domain of VBScript (see the name? VBScript?) as far as Applications languages go python is an excellent choice but it's no better or no worse a choice then the other TOP contenders such as C#, VB.NET, F#, etc. Especially since the .NET framework is at least as extensive in function as perl/python modules; it includes classes for everything you mentioned previously and more.
Language wars, I love them !!
Seriously, if I wanted to ftp from vbscript I would (and have) call the ftp.exe on the command line

Going back to the OP's question, are there 'invisible' characters that can be used as a space ? I remember the old DOS trick of naming a file -255 to hide it no longer works under 32 bit windows

Just a THOUGHT - does
echo   Hallo
give the required indentation ? If so and you can live with a non-indented response, follow the prompt with:
Set /p var=
Which will not add any prompt textseems like W7 set /p strips leading spaces from the prompt string.
Quote from: Salmon Trout on March 30, 2010, 02:17:21 PM
seems like W7 set /p strips leading spaces from the prompt string.
Yes, and so does Vista. The command interpreter is "CMD.EXE" and it seems to be not the same one used in Windows XP that has the same name.

So the challenge here is to either:
1. Modify the way CMD does the SET command to allow e space char.
OR
2. A clean utility that will show a custom prompt to user and take input and store in  something that can be used later.

Hmmm,  "assembly language for windows"  gives almost 2 million hits in Google. Maybe I should write a small machine code thing.

Quote from: BC_Programmer on March 30, 2010, 09:46:49 AM
No. you write it ONCE. and then you can <re-use> that every time.
that's right.! write it once and reuse. that's the beauty of modules/functions. I don't see a vbscript sorting function/library that is able to provide different sorting criteria, like the one i mention, or sorting by keys of a dictionary, or sorting an array according to the keys of another. or sorting by the Nth character position. If i want to do any of these sorting tasks, i just need to plug in my parameters and the sorting function will do the rest.

Quote
a scripting language shouldn't be used in a "production" project. a scripting language should be used for scripting. python can be used for applications programming but that is- get this, outside the domain of VBScript (see the name? VBScript?) as far as Applications languages go python is an excellent choice but it's no better or no worse a choice then the other top contenders such as C#, VB.NET, F#, etc. Especially since the .NET framework is at least as extensive in function as perl/python modules; it includes classes for everything you mentioned previously and more.
that's not correct. PHP is a scripting language and there so many production web sites that use PHP. Similarly for Perl/Python. Why do you think sysadmins use them to do their admin task? Scripting languages can definitely by used anywhere. And Perl/Python are also considered scripting languages (general purpose). no different from vbscript. they both need interpreter to run their script. Quote from: gpl on March 30, 2010, 12:42:43 PM
Just a thought - does
echo   Hallo
give the required indentation ? If so and you can live with a non-indented response, follow the prompt with:
Set /p var=
Which will not add any prompt text

If I understand what you are saying correctly, the problem here is that set /p always(I think) uses its own line, even if you do something like:
Code: [Select]echo  Faking the promptString here & set /p var=The user's input would start on a new line after the fake promptString, which is messy, and is still yet a displayed line that is not getting indented.

I think I'll try the suggestion Salmon Trout gave, which was the third-party Editvar tool.

I think I need to read the C book I bought 2 years ago and just be done with it. ...then again maybe not

Thanks to everyone again for all the help, this is a great community to be a part of, I wish I had more to give back. Quote
I think I'll try the suggestion Salmon Trout gave, which was the third-party Editvar tool.

I think I need to read the C book I bought 2 years ago and just be done with it. Wink ...then again maybe not

You have made a wise choice.
Not the choice of everybody,
Not the choice of the most clever.
But the choice that will work for you.

Quote from: Geek-9pm on March 31, 2010, 01:13:30 PM
Not the choice of the most clever.

Are you saying I'm not clever?   

Quote from: Salmon Trout on March 31, 2010, 01:16:50 PM
Are you saying I'm not clever?   
Ah...er.. uh maybe I shod rephrase that. Quote from: Geek-9pm on March 31, 2010, 01:28:51 PM
Ah...er.. uh maybe I shod rephrase that.

ah ha! so your saying his idea is shoddy! Quote from: BC_Programmer on March 31, 2010, 01:30:10 PM
ah ha! so your saying his idea is shoddy!

I have been to "The shoddy capital of West Yorkshire", the town of Dewsbury. In the 19th century that region of England had a thriving cotton spinning industry and somebody invented a machine for grinding rags or pieces of waste or used cotton cloth, which was called "shoddy", so that the fibres ("fibers" in the US) could be spun into new cloth. The town became the hub of this industry and even in the 1980s the place was full of cotton recycling plants and in the streets you could see little bits of fluffy stuff lying on the ground. It made some people rich and gave jobs to a lot more.
1995.

Solve : Detect RAM with Batch file?

Answer»

Hello everyone,
I'm new here in this community, I need some help with a batch FILE :b.
What I am trying to do is make a Batch File that can detects the total RAM of the system and if its less that, for example 384 MB DO "myapp.exe" IF NOT do "myotherapp.exe"

I already have some of it:
Code: [Select]systeminfo | findstr /c:"Cantidad total de memoria física:" > memtot.txt
My OS is in Spanish so systeminfo gives me that string , it means "Total physcal memory"

I think that the next move will be take the number from the created "memtot.txt" and make it into a variable for compare.. but i don't have an idea how do that :b...

Sorry for my English.
Thanks.
No need for temp file; FOR will parse output of systeminfo directly

Code: [Select]
echo off

for /f "tokens=1-6 delims=: " %%A in ( ' type systeminfo.txt ^| find "Cantidad total de memoria física" ' ) do set ramsize=%%F

REM if your local settings use a comma as thousands separator you must remove it

set ramsize=%ramsize:,=%

echo ramsize %ramsize% MB

if %ramsize% LSS 384 (

myapp.exe

) ELSE (

myotherapp.exe

)

Thank you very much Salmon, here is the code as it works:
Code: [Select]echo off

systeminfo | findstr /c:"Cantidad total de memoria física:" > RAM.TXT

for /f "tokens=1-7 delims= " %%a in (RAM.TXT) do set ramsizedot=%%f

set ramsize=%ramsizedot:.=%

echo RAM SIZE IS: %ramsize% MB

echo.
echo.
echo.

if %ramSIZE% LSS 382 (

echo --- THIS SYSTEM HAS LESS THAT 382 OF RAM ---
) else (

echo --- THIS SYSTEM HAS MORE THAT 382 OF RAM ---
)
del RAM.TXT

I tried to do it without the need of a temp file but im very noob in this. :b¡Muy bien! ¡Que bonita!

Maybe you could try this line and if it works you don't need the file

Code: [Select]for /f "tokens=1-7 delims= " %%a in ( ' systeminfo ^| find "Cantidad total de memoria física" ' ) do set ramsizedot=%%f
I am LEARNING Spanish, I know how to say joder and some other things...
No, it doesn't. well i will use the temp file, its not a big DEAL...

This will be useful for my unnatended setups 

Im glad that you can say me sh*t in spanish too... just KIDDING... LOL Quote from: DJ Iñaki on March 31, 2010, 02:17:34 PM

Im glad that you can say me sh*t in spanish too... just kidding... LOL

joder means f*ck doesn't it? I know how to say me cago en d....... Like the priest in "La Caja" (a film I like)


1996.

Solve : Help Making a Batch file?

Answer»

Hey all ,

Ive recently gone from wired internet , to wireless internet on a G adapter , but ive RAN into a small hiccup when it comes down to online gaming , whilst my ping is GREAT , the service , wireless zero configuration , needs to be off when im gaming or i get latency spikes every 60 seconds or so. So i DISABLE it just before the game starts , how ever once disabled i will be disconnected from the net within 57 minutes , so i need a batch FILE to turn it on then 50-60 minutes later back on again.

Im not 100% sure if this can be done or not , but if it can , can someone please write me something up.

Thanks a million

Tony:]

Slight type there :/

I need to turn it off for 60 minutes or so , then need it to automatically turn its self off for a few seconds then off again.Hello. Many people ASK this type of question here at Conputerhope. In the downloads section of the site (not the forum), you should find a program called Sleep.exe. This program is most likely what you need. If you have trouble finding it, click the little search bar near the top-left and search for Sleep.exe. If you look through some threads, you will also find the download link.

1997.

Solve : find an ip address?

Answer»

What is the command used to display the list of IP address of the computers in LAN or is this even possible?

thanksHi..GO to RUN command, Type cmd, you can find one window on screen...type there ipconfig and PRESS enter..you can get your IP address.

AsifI think you're GOING to need a 3rd party program for this. IPconfig only lists your IP address, not the others on the LAN.

Check out [email protected] or Nmap. Both are free, [email protected] has a GUI.

Good luck.

1998.

Solve : find and to show some word.?

Answer»

in hardware.txt

Code: [Select]USB\VID_0586&AMP;PID_3410\5&21F0A827&0&1                        : ZyXEL G-202 Wireless USB ADAPTER #3
USB\VID_0766&PID_001D\FDC0FD10EA00000FD0FCAF51827474        : USB Mass Storage Device
USB\VID_0AC8&PID_307B\5&21F0A827&0&2                        : ZSMC USB PC CAMERA (ZS0211)
USB\VID_1058&PID_1010\57442D57584C304534395050373135        : USB Mass Storage Device
I want to show in command line. How i do?

USB\VID_0586&PID_3410\5&21F0A827&0&1
USB\VID_0766&PID_001D\FDC0FD10EA00000FD0FCAF51827474
USB\VID_0AC8&PID_307B\5&21F0A827&0&2
USB\VID_1058&PID_1010\57442D57584C304534395050373135

Sorry my bad English? download coreutils or gawk, and on command line

Code: [Select]C:\test>cut -f1 -d":" hardware.txt
USB\VID_0586&PID_3410\5&21F0A827&0&1
USB\VID_0766&PID_001D\FDC0FD10EA00000FD0FCAF51827474
USB\VID_0AC8&PID_307B\5&21F0A827&0&2
USB\VID_1058&PID_1010\57442D57584C304534395050373135

C:\test>gawk -F":" "{print $1}" FILE
USB\VID_0586&PID_3410\5&21F0A827&0&1
USB\VID_0766&PID_001D\FDC0FD10EA00000FD0FCAF51827474
USB\VID_0AC8&PID_307B\5&21F0A827&0&2
USB\VID_1058&PID_1010\57442D57584C304534395050373135
In batch file. Can you do ?  Quote from: mepmep on April 01, 2010, 08:32:12 AM

In batch file. Can you do ? 
sure, open your editor, type the command in,
Code: [Select]gawk -F":" "{print $1}" file
then save as mybatch.bat, that's it.
1999.

Solve : hostname in batch file?

Answer»

how can i get the HOSTNAME from a workstation and make a folder NAMED the same as the workstation? i have tried "setlocal, set hostname=%hostname%, endlocal".

or in other words, "hostname" is a command. how can i make a file from the output of a command?

xpp sp3.

i am trying to backup multiple folders to one folder with the name of the workstation it came from. Im assuming you mean appending to a file, when you say "make a file from the output of a command"

> Clears the file
>> adds a line to a file

example:
echo hello>>myfile.txti am trying to GO to a workstation and run my batchfile. it needs to find the computer name and make a file with the name of the workstation. then it will backup some folders and save them under the folder that it just created with the computer name so i can find it later to restore them. i have the batch file created and it can store folders under the %username% VARIABLE, but i would MUCH rather have it store under computer name.

example: when i type "echo %username%" in a cmd it displays my user name. but when i type "echo %hostname%" it does not display. i can however type "hostname" by itself to get the workstation name....

thanks in advance...on your command prompt, type Code: [Select]env. You can see computer name there.env does not work. isnt that for linux? i need to create a folder with the name of the pc...ComputerName is a system variable that you can use:

md %computername%

OR

You can still use the hostname command in a batch file:

Code: [Select]echo off
for /f %%a in ('hostname') do (
  md %%a


Good luck. 

Env works on WinXP but you can also use set to list all the environment variables.echo off
md c:\%computername%

or if you want to name a file:

echo off
echo. >> c:\%computername%.txt

thank you both, i ran the set comand to see the variables but "computername" was not in there. but it does work with computername so thanks again... Quote from: 037 on March 31, 2010, 07:06:40 AM


"Hostname" is a command. How can I make a file from the output of a command?



C:\>type  thirty7.bat
Code: [Select]echo off

hostname  >  host.txt

type host.txt

pause
md Okie
cd Okie

echo hello okie > host.txt

type host.txt
Output:

C:\>thirty7.bat
Okie
Press any key to continue . . .
hello okie

C:\Okie>another greg Quote from: ghostdog74 on April 04, 2010, 06:10:09 PM
another greg
I already sent a PM to Nathan... Quote from: ghostdog74 on March 31, 2010, 08:07:48 AM
on your command prompt, type Code: [Select]env. You can see computer name there.

I use XP pro SP3 and there is no env command. Quote from: BobJordan on April 04, 2010, 08:55:11 PM
I use XP pro SP3 and there is no env command.
Here.
2000.

Solve : generate text files with replaceable parameters inside?

Answer»

Here is a text (inf) file I am using INSIDE a BATCH file (call it warp.inf) with 339 and ne as replaceable parameters somehow

[Source]
Type                       =  GeoTiff
SourceDir                = "C:\WRK_STD_TIFS"
SourceFile               = "339_ne"
Layer                      = Imagery
Variation                 = Day
NullValue                = 0,0,0
[Destination]
DestDir                   = "C:\WRK_BGLS"
DestBaseFileName   = "339_ne"
DestFileType           = BGL
LOD                       = Auto

I want to loop through the batch file, bumping a parameter %1 (339) to 339,340,341... and a parameter %2 to ne,se,SW,..my PROBLEM is, I need to bump the text (339, .. ne) inside my text file while I am bumping the replaceable parameters OUTSIDE in the batch file itself.

So partway through the batch file, I have to replace the text (339,ne) to (340,ne) inside warp inf, then continue on.

joe 339 ne
line 1 blah
line 2 .....warp.inf...blah blah
line n blah

joe 340 sw
line 1 blah
line 2 .....warp.inf...blah blah  now I have to use a changed txt file (warp inf), changing 339 to 340 INSIDE..etc
line n blah



Could you be a bit clearer about this INSIDE and OUTSIDE thing? I see you've written them in capital letters, but that doesn't make it any easier to know what you are getting at.I have a series of routines I want to run on a sequentially numbered set of files.

I want to bump the ID number of the file and one by one put the outputs in a storage folder.
So far so good. No problem
However........

One of the routines requires the use of a text file which inside itself  needs the ID number of the file I'm working on.

routine 1  .........
routine 2 ..........
routine 3 ........... .......warp.inf ...........
routine 4 .......... etc. 

I need to know if it is possible in the middle of a series of routines, to bump the ID number INSIDE the file with a replaceable parameter, then use the file (to continue the routine).
It's a text file nested INSIDE a routine collection of steps, where I need to bump (write) the number IN the text file.. Hope this helps.

In short, how do you edit a file on the fly with a replaceable parameter, then close the file and immediately use it.let me get this, you have sequential numbered files ( you should have provided samples of the format in your question) example ,  "some_name_001.txt" , and then you want to get the "001" into a variable. Then you want to place this "001" into the text file , right?  Otherwise, you really want to try providing more clear sample/examples of input and output (use actual data and not "blah blah" or dots .... ) of what you want to do. After reading 2 posts from your, i  still don't fully understand what is it you actually want. And what is 'routine' ?, show examples. Any also show any batch you have already written that will provide a more clearer picture.I really blew it with my original question so here is a better way to describe it..

here is a batch file I need to run on hundreds of aerial photos...

echo on
resample.exe C:\PHOTOREAL\225_nw.inf
resample.exe C:\PHOTOREAL\225_sw.inf
etc
etc

225_nw.inf is a text file which needs the ID 225_nw INSIDE it in order for resample to work.

here is the text of 225_nw.inf.

[Source]
Type                   = GeoTiff
Layer                  = Imagery
SourceDir           = "C:\PHOTOREAL"
SourceFile          = "m_225_nw.tif"
Variation           = Day
NullValue           = 0,0,0
[Destination]
DestDir              = "C:\PHOTOREAL"
DestBaseFileName       = "m_225_nw"
UseSourceDimensions = 1
CompressionQuality    = 100


Right now I am faced with producing hundreds of text files like the above each with the ID as the title and having the
same ID inside as well.

I was hoping there is a way to create a multiline text file  (myfile.inf)
on the fly with my single  replaceable parameter %1 ...225_nw,...225_sw...just prior to the
resample.exe C:\PHOTOREAL\225_nw.inf line.

My batchfile would then look something like

echo on
...code to create inf file for 225_nw
resample.exe C:\PHOTOREAL\225_nw.inf
...code to create inf file for 225_sw
resample.exe C:\PHOTOREAL\225_sw.inf
etc
etc

My excuse is (a) my DOS Manual is up north, and
                     (b) I am pretty much a newbie in DOS, and
                     (c) my wife absolutely refuses to do this gruntwork....
The alternative would be to have a batch file to open a text file, find a string(which varies each time) , replace the string and close the file with a new name. Is this possible? well this file can automate the creation of the files

set /a id=1
:A
set /a ids=%id%
echo [Source] >> %id%_nw.inf
echo Type                   = GeoTiff >> %id%_nw.inf
echo Layer                  = Imagery >> %id%_nw.inf
echo SourceDir           = "C:\PHOTOREAL" >> %id%_nw.inf
echo SourceFile          = "m_%id%_nw.tif" >> %id%_nw.inf
echo Variation           = Day >> %id%_nw.inf
echo NullValue           = 0,0,0 >> %id%_nw.inf
echo [Destination] >> %id%_nw.inf
echo DestDir              = "C:\PHOTOREAL" >> %id%_nw.inf
echo DestBaseFileName       = "m_%id%_nw" >> %id%_nw.inf
echo UseSourceDimensions = 1 >> %id%_nw.inf
echo CompressionQuality    = 100 >> %id%_nw.inf
if %id%==10 goto :eof
set /a id=%ids%+1
goto A

those GLOWING numbers are what you change
1 is the starting number
10 is the ending numer
1 is the interval countThank you..I am partway there. I did not understand the loop syntax you used , so I rewrote your suggestion in two separate (cruder) batch files . (My Inf file names have to be alphanumeric)

makethisinf.bat

echo [Source]                             >> %1%.inf
echo Type                = GeoTiff        >> %1%.inf
echo Layer               = Imagery        >> %1%.inf
echo SourceDir           = "C:\PHOTOREAL" >> %1%.inf
echo Variation           = Day            >> %1%.inf
echo SourceFile          = "%1%.tif"      >> %1%.inf
echo NullValue           = 0,0,0          >> %1%.inf
echo [Destination]                        >> %1%.inf
echo DestDir             = "C:\PHOTOREAL" >> %1%.inf
echo DestBaseFileName    = "%1%"          >> %1%.inf
echo UseSourceDimensions = 1              >> %1%.inf
echo CompressionQuality  = 100            >> %1%.inf


run_makethisinf.bat
makethisinf m_930_nw
makethisinf m_930_ne
makethisinf m_930_sw
makethisinf m_930_se
pause

Two problems I do not understand.....
One....
echo SourceFile          = "%1%.tif "          >> %1%.inf
echo DestBaseFileName    = "%1%"               >> %1%.inf

My system produces the first named text file perfectly (many thanks) , but will not produce
the lines
SourceFile          = m_930_nw.tif
DestBaseFileName    = m_930_nw


Two, the second batch file run_makethisinf.bat only runs the first line. I think I am very close to a solution here but I am mystified about these two remaining issues. Again, much appreciated.here's a Python script if you are open to other languages

Code: [Select]template="""
[Source]
Type                   = GeoTiff
Layer                  = Imagery
SourceDir           = "C:\PHOTOREAL"
SourceFile          = "%s.tif"
Variation           = Day
NullValue           = 0,0,0
[Destination]
DestDir              = "C:\PHOTOREAL"
DestBaseFileName       = "%s"
UseSourceDimensions = 1
CompressionQuality    = 100
"""

mylist = ["m_930_nw","m_930_ne","m_930_sw","m_930_se"]
for makeinf in mylist:
   print "making inf %s ...." % makeinf
   open("%s.inf" % makeinf,"W").write(template % (makeinf , makeinf))

save as makeinf.py and on command line
Code: [Select]
C:\test>python test.py
making inf m_930_nw ....
making inf m_930_ne ....
making inf m_930_sw ....
making inf m_930_se ....

C:\test>more m_930_nw.inf

[Source]
Type                   = GeoTiff
Layer                  = Imagery
SourceDir           = "C:\PHOTOREAL"
SourceFile          = "m_930_nw.tif"
Variation           = Day
NullValue           = 0,0,0
[Destination]
DestDir              = "C:\PHOTOREAL"
DestBaseFileName       = "m_930_nw"
UseSourceDimensions = 1
CompressionQuality    = 100

C:\test>more m_930_ne.inf

[Source]
Type                   = GeoTiff
Layer                  = Imagery
SourceDir           = "C:\PHOTOREAL"
SourceFile          = "m_930_ne.tif"
Variation           = Day
NullValue           = 0,0,0
[Destination]
DestDir              = "C:\PHOTOREAL"
DestBaseFileName       = "m_930_ne"
UseSourceDimensions = 1
CompressionQuality    = 100


Quote from: brute_force on April 01, 2010, 08:33:24 PM


run_makethisinf.bat

makethisinf m_930_nw
makethisinf m_930_ne
makethisinf m_930_sw
makethisinf m_930_se
pause

Two, the second batch file run_makethisinf.bat only runs the first line.

I will leave problem (1) for the other guy, but I can see straight away why only the first line of run_makethisinf.bat gets executed. The reason is this:

If you, in a batch file, want to run another batch file, there are two ways of doing it.

1. Use its name alone. In this case control is handed over to the second batch file permanently, and the first batch file terminates. In other words you never go back.

2. Precede its name with the CALL keyword. In this case the first batch hands over control to the second batch file temporarily, and waits for it to finish. When that happens, control is passed back to the calling (first) batch file and execution continues on the next line.

So your run_makethisinf.bat should look like this

Code: [Select]call makethisinf m_930_nw
call makethisinf m_930_ne
call makethisinf m_930_sw
calll makethisinf m_930_se
pause

Thanks for the help. If there is no  way to get those two lines to resolve themselves, my fallback is this (for northeast,northwest,southeast, and southwest. It requires that I edit each xxx once in notepad once it is done.   I'm getting there, but ..........


echo
call makethisinf4 m_930_nw m_930_ne m_930_se m_930_sw
call makethisinf4 m_931_nw m_931_ne m_931_se m_931_sw
pause

echo [Source]                                >> %1%.inf
echo Type                = GeoTiff           >> %1%.inf
echo Layer               = Imagery           >> %1%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %1%.inf
echo Variation           = Day               >> %1%.inf
echo SourceFile          = "m_xxx_nw.tif"    >> %1%.inf
echo NullValue           = 0,0,0             >> %1%.inf
echo [Destination]                           >> %1%.inf
echo DestDir             = "C:\PHOTOREAL"    >> %1%.inf
echo DestBaseFileName    = "m_xxx_nw"        >> %1%.inf
echo UseSourceDimensions = 1                 >> %1%.inf
echo CompressionQuality  = 100               >> %1%.inf
echo [Source]                                >> %2%.inf
echo Type                = GeoTiff           >> %2%.inf
echo Layer               = Imagery           >> %2%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %2%.inf
echo Variation           = Day               >> %2%.inf
echo SourceFile          = "m_xxx_ne.tif"    >> %2%.inf
echo NullValue           = 0,0,0             >> %2%.inf
echo [Destination]                           >> %2%.inf
echo DestDir             = "C:\PHOTOREAL"    >> %2%.inf
echo DestBaseFileName    = "m_xxx_ne"        >> %2%.inf
echo UseSourceDimensions = 1                 >> %2%.inf
echo CompressionQuality  = 100               >> %2%.inf
echo [Source]                                >> %3%.inf
echo Type                = GeoTiff           >> %3%.inf
echo Layer               = Imagery           >> %3%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %3%.inf
echo Variation           = Day               >> %3%.inf
echo SourceFile          = "m_xxx_sw.tif"    >> %3%.inf
echo NullValue           = 0,0,0             >> %3%.inf
echo [Destination]                           >> %3%.inf
echo DestDir             = "C:\PHOTOREAL"    >> %3%.inf
echo DestBaseFileName    = "m_xxx_sw"        >> %3%.inf
echo UseSourceDimensions = 1                 >> %3%.inf
echo CompressionQuality  = 100               >> %3%.inf
echo [Source]                                >> %4%.inf
echo Type                = GeoTiff           >> %4%.inf
echo Layer               = Imagery           >> %4%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %4%.inf
echo Variation           = Day               >> %4%.inf
echo SourceFile          = "m_xxx_se.tif"    >> %4%.inf
echo NullValue           = 0,0,0             >> %4%.inf
echo [Destination]                           >> %4%.inf
echo DestDir             = "C:\PHOTOREAL"    >> %4%.inf
echo DestBaseFileName    = "m_xxx_se"        >> %4%.inf
echo UseSourceDimensions = 1                 >> %4%.inf
echo CompressionQuality  = 100               >> %4%.infIt seems to me that your problem because you need to know that (unlike ordinary batch variables) parameters passed to a batch file from the command line or from another batch only have ONE percent sign, placed before the figure. Not after as well. Like this...

echo first parameter is %1
echo second parameter is %2

etc

Also did you realise that >> appends data to an already existing file (if there is one)?




It's working perfectly now.......your point did the trick..

in the example that mat123 posted I interpreted the second % sign erroneously......

This code works perfectly.... I will use Excel to produce the batch file with the numbers bumped thru the entire range in the upgraded run_makethisinf

echo [Source]                                >> %1%.inf
echo Type                = GeoTiff           >> %1%.inf
echo Layer               = Imagery           >> %1%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %1%.inf
echo Variation           = Day               >> %1%.inf
echo SourceFile          = "%1.tif"          >> %1%.inf
echo NullValue           = 0,0,0             >> %1%.inf
echo [Destination]                           >> %1%.inf
echo DestDir             = "C:\PHOTOREAL"    >> %1%.inf
echo DestBaseFileName    = "%1"              >> %1%.inf
echo UseSourceDimensions = 1                 >> %1%.inf
echo CompressionQuality  = 100               >> %1%.inf
echo [Source]                                >> %2%.inf
echo Type                = GeoTiff           >> %2%.inf
echo Layer               = Imagery           >> %2%.inf
echo SourceDir           = "C:\PHOTOREAL"    >> %2%.inf
echo Variation           = Day               >> %2%.inf

..................................etc
...................................etc

I am grateful for the help......I do understand about appending to an existing file, which I suspect could be used to shorten the makethisinf.bat  program if  a large number of lines were simply characters lines with no replaceable parameters....like the first 5 lines here.. bf    just because you don't understand how something works doesn't mean it's wrong.