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.

8351.

Solve : Avoid empty folder / Convert byte in Kb?

Answer»

Hello,
My script (below) builds an HTML index of files in a folder (recursively).

1. My TEST to avoid empty folders (or folders with sub-folder but no file):
IF EXIST "%%f\*.*"
doesn't work.

In my example: http://www.airfirst.ch/b2/IndexOfRootTree.html
I WOULD avoid those folders:
- C:\RootFolder\empltyFolder
- C:\RootFolder\subfolderButNofile

Do you have any idea to fix this bug?


2. Using DOS commands, how could you CONVERT:
- 10300 [bytes] in 10 [Kb]
- 10800 [bytes] in 11 [Kb]

Thanks


Code: [Select]SET z=IndexOfRootTree.html
TYPE NUL>"%z%"
(
ECHO.^<HTML^>^<HEAD^>
ECHO.^<STYLE type="text/css"^>
ECHO..M1{FONT:bold 14Px "Arial";background-color:#D1D4F2}
ECHO..C1{text-align:left}
ECHO.^</STYLE^>
ECHO.^</HEAD^>
ECHO.^<BODY^>
FOR /f "Delims=*" %%f in ('DIR /on /ad /s /b') DO (
IF EXIST "%%f\*.*" (
CD "%%f"
ECHO.^<TABLE border="1" cellpadding="3" cellspacing="0"^>
ECHO.^<TR^>^<TD class=M1 colspan=2^>%%f^</TD^>^</TR^>
FOR /f "Delims=" %%a in ('DIR /b /a-d *.*') DO (
ECHO.^<TR bgcolor=#E4E6A5^>^<TD class=C1^>%%~a^</TD^>
ECHO.^<TD^>%%~za^</TD^>^</TR^>
)
ECHO.^</TABLE^>^<BR /^>
)
)
ECHO.^</BODY^>^</HTML^>
)>>"%z%"

8352.

Solve : NTFS from RAW?

Answer»

My HD locked up and is now in RAW format instead of NTFS. This is a secondary HD and not my boot-up drive. This happened to me a long time ago (about a year) and I found an MS DOS command that would check out my HD and put it BACK to NTFS. The commands are not chkdsk or scandisk ... these do not work. What are other commands I can use to check the bad HD out and possibly get it back to NTFS WITHOUT reformatting it?RAW is not a good sign.
It is most commonly caused by a power spike or an external drive being unplugged before using the safely remove hardware tool.
There is no DOS command that will get this back to normal other than FDisk which will ERASE all the data and allow you to format and use the drive again.

You COULD try running chkdsk /r from a command prompt but usually this is an excersise in futility.
Best bet is to visit a Freeware site like sourceforge and read up on some NTFS data RECOVERY programs.

You have about a 1 in 5 chance of retrieving all your data...1 in 5 is probably a bit optimistic isn't it? I personally had this problem about a year ago. happened when I sent a firmware upgrade for my CD burner to my third HD(yes it was an accident). long story short, it used to be 4GB, now the BIOS only recognizes 2GB, and my burner died (no light or anything on boot, door won't open, etc..). and no, I did not recover any data. I can't remember the details, it was so long ago. I didn't fix it though, so the details would just add fluff anyway. But hey! the drive works fine now after formatting! I'm an optimistic person by nature...Well then call me a pessimist.

8353.

Solve : .batch file problem?

Answer»

ok..i have a problem with a .batch file im running.... lets say i open "a.bat" the code i have so far is:Code: [Select]echo (
start iexplore.exe www.google.com
exit
)
>"a1.bat
start a1.batnow i know this is wrong...i also tried
Code: [Select]echo start iexplore.exe www.google.com|exit>"a1.bat
start a1.bat
..now before u start saying "just do 'start www.google.com'", i NEED to open google through this format, and be able to for future reference, and not just OPENING google...
thx all!In the TV VERSION of M*A*S*H, Major Charles Emerson Winchester said he did one thing at a time, did it very well and then moved on.

Words to live by. Don't try to do everything at once:

Code: [Select]echo start iexplore.exe www.google.com > a1.bat
echo exit >> a1.bat

Once a1.bat is created, you can launch the program with start a1.bat

thanks SIDEWINDER ! that really helped, and now it doesnt break ANYMORE I've come across another problem with this...Code: [Select]...
echo echo Hello World >> a1.bat
echo pause>nul >> a1.bat
...APPEARS to work fine, but when I call or start a1.bat it is just "pause" instead of "pause>nul". Is there anyway to get it to say "pause>nul" through the format above? And if not, is there anyway I can do this that is automated?
Thx!Try using the escape character (^):

Code: [Select]echo pause ^> nul >> a1.bat

8354.

Solve : Extracting data from Excel and creating folders and subfolders?

Answer»

I need to create a batch file that will extract data from an Excel spreadsheet to a .txt file and from there take the data and create folders and subfolders from it. Here's an example of what I need.

TEXT FILE
1 A
2 A Each letter should be the main folder. Each number should be a subfolder inside the letter folder.
3 A For example, folder A would have subfolders 1,2,3,4 in it and folder B would have subfolders
4 A 5,6,7,8 in it.
5 B
6 B
7 B
8 B
etc........

Any help on this would be greatly appreciated. It would save literally weeks of entering data and thousands of dollars. Thanks ahead of time!Batch code cannot process Excel spreadsheets which have a proprietary organization. If you can save the spreadsheet as a comma separated values (CSV) file, this little snippet may work for you.

Code: [Select]@echo off
set home=%cd%
for /f "tokens=1-2 delims=," %%x in (input.csv) do (
if exist %home%\%%y\nul (
cd %home%\%%y
md %%x
) else (
cd %home%
md %%y
cd %home%\%%y
md %%x
)
)

I made the assumption that the letters were in column 2 and the numbers in column 1 of the spreadsheet and that the CSV file would look like this:

Code: [Select]1,A
2,A
3,A
4,A
5,B
6,B
7,B
8,B

An easier way would be to USE VBScript (which is installed with Windows) or to write a macro to run inside Excel itself.

Good luck. QUOTE from: Sidewinder on December 14, 2007, 12:59:16 PM

Batch code cannot process Excel spreadsheets which have a proprietary organization. If you can save the spreadsheet as a comma separated values (CSV) file, this little snippet may work for you.

Code: [Select]@echo off
set home=%cd%
for /f "tokens=1-2 delims=," %%x in (input.csv) do (
if exist %home%\%%y\nul (
cd %home%\%%y
md %%x
) else (
cd %home%
md %%y
cd %home%\%%y
md %%x
)
)

I made the assumption that the letters were in column 2 and the numbers in column 1 of the spreadsheet and that the CSV file would look like this:

Code: [Select]1,A
2,A
3,A
4,A
5,B
6,B
7,B
8,B

An easier way would be to use VBScript (which is installed with Windows) or to write a macro to run inside Excel itself.

Good luck.

And suppose a person had never used VBScript in an Office application before... Where might he find some info on how to perform the specific TASK he needs to?Technically if you write code for an Office Application within the application you use VBA. If you write code for an Office Application that runs EXTERNAL to the application you use VBScript or any other Windows Script language that can create automation objects.

You can still do your original request in batch, but as mentioned batch code cannot read an Excel file directly. You can however save an Excel file as a CSV file by choosing Saveas from the File menu. When the dialog appears, give the file a name then choose CSV (comma delimited) from the save as type drop down box. The CSV file will be input to the script posted.

Help with VBA and VBScript can be found all over the net. In addition each Office Application comes many pages of Help (F1). The Microsoft Script Center has a Office Section geared toward their Office products.

There is a help file (script56.chm) found on most Windows installations that can help you learn all about VBScript and/or JScript.

8355.

Solve : 3 questions?

Answer»

1. How can i make bat wich will make files in RANDOM folders ?
2. It is possible to code/decode text e.g. in rot13 ??
i DONT wont do it in "for" etc
3. How to FIND in files text from one word to other ?
like i wont to find tex2 form txt1 to txt3
Code: [Select]txt1 txt2 txt3thanks in advance
our friend Dusty says me to post config etc
so:
Vista/XP
4gb RAM
Intel QX6850
Striker Extreme
2x 8800Ultra OC SLIAnybody know?? Please1)
mkdir %random%

2)unsure about in the command window but otherways easily google it

3)use findstr string file.txt unsure what you mean "one word to other"

example:
cd\myfiles
findstr /I Titlename *.txt

would SEARCH *.txt (all text files) in (myfiles) folder, and display ones with "Titlename" in them /I is ignore string casethanx!
but about the 3 question. I wont to find "some text" in EG test.txt betwen "before word" to "after word"
"before word" "some text" "after word" You will need to use the regular expression function in FindStr
Type FindStr /? at the command prompt to see the options

If you only want to find 'myword' between 'firstword' and 'lastword', separated only by a single space, then you can search for

firstword myword lastword

But if there are varying amounts of space, commas tabs etc between, then the regular expression is the way to go

GrahamYes but what will be if i dont have 'myword' but the odershere's some vbscript code to get you started.
Code: [Select]' 1) create directory with random number
Randomize
numRandom = Int((65535 * Rnd) + 1)
WScript.Echo numRandom
Set objFSO=CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder("C:\temp\" & numRandom) 'create directory

'2) rot13 encrypt
strInput = "testing"
n = 13
For i = 1 To Len(strInput)
strConverted = Chr(Asc(Mid(strInput, i, 1)) + n)
WScript.StdOut.Write(strConverted)
Next


'2) rot13 decrypt
strInput = "testing"
n = 13
For i = 1 To Len(strInput)
strConverted = Chr(Asc(Mid(strInput, i, 1)) - n)
WScript.StdOut.Write(strConverted)
Next

WScript.Echo

' 3) find words between 2 words
strTest = "txt1 tex2 txt2"
indexFirstWord = InStr(1,strTest,"txt1")
WScript.Echo indexFirstWord
indexSecondWord = InStr(1,strTest,"txt2")
WScript.Echo indexSecondWord
indexstart = indexFirstWord + Len("txt1")
strWordBetween = Trim(Mid(strTest,indexstart,indexSecondWord - indexstart))
WScript.Echo strWordBetween
that 3 is impossible in .bat file ?? coz i cant make it work in vbs

8356.

Solve : Batch file question.?

Answer»

Is there a code I can use to put a desktop background when SOMEONE opens it?

Thanks
S_R_SYou can CHECK out this VBScript solution for an example. PAY particular ATTENTION to the part about refreshing the desktop.

Good luck. Thank you. =)

8357.

Solve : Send Command Via a Cmd Progam?

Answer»

I have been working on a small program for some time and have been having some DIFFICULTY with it. All I need the program to do is PASS a COMMAND to the device it is stored on. So that when the program is called to run it PASSES the command to the device. The device works with sisc commands.

I have WORKED on other projects that will send the command to the device from an HTML webpage. I used:

OnClick="sendcommand (sisc)"

This worked for the other pages that I created. Now I am trying to create a page that calls the program that has the sisc send parameter in it.

Any help would be Great.

8358.

Solve : another batch file problem....?

Answer»

Ok, so I need to make a batch file that calls a batch from the C:\, then goes back to the file where the batch started, and calls and/or starts another batch. I have tried a couple of codes: (a.bat is in the C:\, b.bat is in the same file as the batch being run)Code: [SELECT]set 1=%CD%
pause>nul
cd\
call a.bat
cd "1"
call b.bat
pause>nulCode: [Select]@echo off
set 1="%~dp0"
cd\
call a.bat
cd "1"
call b.bat
pause>nulCode: [Select]set choice="%CD%"
set /p choice="%CD%">nul
if '%choice%'=='%CD%' goto :1
:1
cd\
call a.bat
cd "%choice%"
call b.bat
pause>nul but none of the above seem to work. So I guess what I'm asking is, Is this possible? and if so, what would the correct code be?
Thanks!You're making this much harder then it has to be. Your first example was the easiest to fix.

Code: [Select]set 1=%CD%
pause>nul
cd\
call a.bat
cd %1%
call b.bat
pause>nul

The KISS METHOD would be:

Code: [Select]call \a.bat
call b.bat

I don't recommend using numerics as the target of a set command. They are too easily CONFUSED with command line arguments. Batch code is cryptic enough.

Someday, someone will have to explain pause>nul to me.

Sidewinder, happy to oblige

Pause does 2 THINGS, waits for a keypress and DISPLAYS
Press any key to continue ....

Redirecting the output of Pause means it will still wait for a keypress, but the message will not appear, it is usually accompanied by a customised message using Echo

......
Echo Processing complete, press a key to exit
Pause>Nul

GrahamQuote

Sidewinder, happy to oblige

Pause does 2 things, waits for a keypress and displays
Press any key to continue ....

Redirecting the output of Pause means it will still wait for a keypress, but the message will not appear, it is usually accompanied by a customised message using Echo

......
Echo Processing complete, press a key to exit
Pause>Nul

Thank you Graham.

And to think all these decades I've been ecstatic with the simple return of the command prompt.
8359.

Solve : deleting an "access denied" file?

Answer»

hi guys, i'm trying to delete some empty folders, but am UNABLE to do so through the conventional ways of pressing delete just wondering if, (and how) i can delete them through Command prompt; in an attempt to bypass the "ACCESS denied" bitHave you tried using "MoveOnBoot" to delete the file?
What Operating System is this?Try this in safe mode.

To TAKE full control of a file:

  • Right click the file, select properties.
  • Hit security TAB, then click on your user name.
  • Hit edit, then click on your user name on the pop up SCREEN
  • Check the box marked "full control" under the allow heading
  • OK out of all dialog boxes.
8360.

Solve : Can you explain the Call command in batch??

Answer»

I'V read about it but, I can't comprehend it. Can you try to describe it?

Thanks,
S_R_SCall is used to execute a batch script from within ANOTHER batch script. Control is handed back to the calling script.

Try this: Create two batch scripts which I have named batchone.bat and batchtwo.bat as below

---------------------------------------------------------------------------------------------
Batchone.bat

@echo off
cls

echo This is batch one.....
echo.
echo Press any key to continue...

pause &GT; nul

cls

call batchtwo.bat

echo Now back in batch one again...
echo.
echo Press any key to end...

pause > nul
cls

-----------------------------------------------------------------------------------------------

Batchtwo.bat

@echo off
cls

echo Now this is batch two...
echo.
echo Press any key to return to batch one...

pause > nul

cls

-----------------------------------------------------------------------------------------------
Save them in your Path then execute batchone.bat. Hopefully you will see when batchone calls batchtwo then batchtwo hands back to batchone.


Here is the BATCHING master on Call.

Good luck

8361.

Solve : Batch File to Copy contents of a CD and move to a shared folder?

Answer»

I am trying to get a batch file that will copy the contents of a CD and move them to a share on a server and ignore the overwrite prompt. I am not familiar with writing batch files so if anyone has a template that i could just input the LOCATIONS that the copy and move will move to.

Any help will be great.If anyone has any ideas or sample script please let me know.

Help is appreciated

I assume that you are using the Copy command.
The help gives this
Copy /?
Copies one or more files to another location.

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]

source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
/D Allow the destination file to be created decrypted
destination Specifies the DIRECTORY and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, if available, when copying a file with a
non-8dot3 name.
/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. Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, SPECIFY a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

So you would need to add the /Y parameter to ignore the overwriting of the previously existing files

Graham

8362.

Solve : Extract File Name from Folder?

Answer»

Please Help! I am trying to find a way to extract a file name from a DIRECTORY of files. For example, if you have a FOLDER named "C:\scanadm\file\in" that contains files
12343567.txt
7654321.txt

and you want to extract the name of each file in a for loop and store it in a variable:

FOR /R C:\scanadm\file\in %A IN (*.*) DO (Get Individual Name of File and Put in Variable)

How do you do this? I have been all over the internet, and cannot find this anywhere - It can't be that hard!!set un1=0
for /f "tokens=1* delims=" %%a in (' ') do (
call set /a un1=%%un1%%+1
call set D.%%un1%%=%%a
)

variables would be %D.1% %D.2% ectQuote

FOR /R C:\scanadm\file\in %A IN (*.*) DO (Get Individual Name of File and Put in Variable)

Not sure what the PROBLEM is. You have a variable (%A) which will contain the FULLY qualified file name.

If you don't want the path info, you can use:
Code: [Select]FOR /R C:\scanadm\file\in %A IN (*.*) DO (ECHO %~nxA)

Don't recommend using %~nxA; the /R switch walks the directory structure (recursion) and you may want to keep file names unique.




8363.

Solve : sending/accessing/running files and programs over a LAN?

Answer»

Specifically, I'm wondering if there is a way to run programs remotely on another COMPUTER with command prompt over a LAN and how to do so, but any help on how to do anything in the title will help.You can use psexec - free tool from sysinternals (now microsoft)
http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx
works like a charm! - just give your credentials for the REMOTE computer, specify your program/DOS commands and off you go
thanks, i'll give it a tryok i tried this program and it did not work

i'm trying to do this on my school's computers so that may explain why that program did not work

i am able to ping any IP on the school's network but when i tried that program it said something like -ip address- could not be reachedQuote from: shade963 on DECEMBER 19, 2007, 08:29:42 AM

i'm trying to do this on my school's computers
That raised some red FLAGS for me... Maybe you should explain what you're trying to accomplish and why.
8364.

Solve : Cannot use External DOS commands?

Answer»

When I RUN a cmd session from Windows the only DOS commands I can run are Internal like DIR, DEL, CD. But DOS will not recognise any External DOS commands like XCOPY, NETSTAT, HELP, FIND etc.
I get error message: "'command' is not recognosed as an internal or external command, operable program or batch program."
I checked system32 directory and these files do exist. I checked my path and system32 is part of my path.
I never had a problem with this before with this PC, problem started recently. What could be wrong?
Running Windows XP PRO SP2.
Welcome to the CH forums.

I can only suggest that your start cmd.exe then cd to windows\System32 and try running a few externals from there. If that works then recheck your path to confirm that %systemroot%\System32 is correctly displayed.

Good luck

When I CD to windows\System32 the External commands work!
This is my Path:

PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;C:\Program Files\Executive Software\Diskeeper\;C:\Program Files\Support Tools\;C:\WINDOWS\System32\Wbem

I checked %SystemRoot% and it is correctly set as C:\Windows

I just now changed Path by entering "path %path%;C:\Windows\System32" and the external commands work from any directory. So, why wasn't the original path good enough? And will path revert back after reboot, or what is a permanent fix? I think the problem is that the Path command is a little too literal, it is trying to find a directory called %systemroot% - it isnt expanding the environment variable.

Change it to be the actual directories and I think it will work

GrahamOkay, so how do I edit the Path list so it will be permanent after reboot? Do I use the old fashion way with Autoexec.bat?
Thanks for your continued support.To edit Path: (XP)

Right click My Computer then click Properties -or- press the Windows key+Break to bring up the System Properties window.

Click Advanced>Environment Variables>Path (In System Variables pane)>Edit

Change the entries to what you want then click OK in the Edit pane then Ok in the Environment Variables window and exit the System Properties windows.

Good luck

This can also be done by creating a desktop shortcut to .cmd and right CLICKING the shortcut...From Explorer navigate to system32...right clik cmd. and create shortcut.
Drag the shortcut to the desktop.
Now when you right clik the shortcut and select Properties you will see all the option you can change for the Command Prompt loading including Target etc.Sorry, I deleted my last RESPONSE in error. It questioned how to set the Environment Variables using Quote

This can also be done by creating a desktop shortcut to .cmd and right clicking the shortcut.

I'm up to speed on this feature but find that altering the Shortcut Properties does not edit the Environment Variables in any way. Also found that in order to access the External Commands using a shortcut, the Start In has to be C:\Windows\System32\
8365.

Solve : FOR command?

Answer»

how to do .bat file in for COMMAND that for the space will be "+" so if i type aa aa aa the output will be aa+aa+aacheck out string substitution in
set /?

Grahami tryied it but cant MAKE it work C:\WINNT>set fred=aa aa aa

C:\WINNT>set fred=%fred: =+%

C:\WINNT>echo %fred%
aa+aa+aa

tada !!
Grahamthanks mate !

8366.

Solve : .bat question rename question?

Answer»

I NEED to do a renmame based on the FIRST two line in a .txt file.

Here is how I get the file-

dir /A-D /O:-D /B | findstr txt > list.txt



edlin list.txt

3,9999D

E

This will leve me with two lines in the list.txt "line 1 and line 2"

The NEXT thing I want to do is:

rename (filename in line one of list.txt) newfilename.txt
rename (filename in line two of list.txt) newfilename2.txt

This seems like it should be doable but I cannot FIGURE it out.

Thanks for the help!

Kevin
You could try this

Code: [Select]:: put all the txt files in reverse date order into a file
Dir /A-D /O:-D /B *.txt > list.txt
:: create a dummy blank file
Echo.>blank
:: pull off the top line from the file
Set /P FileName=<list.txt
:: do the rename
Ren "%FileName%" newfilename.txt
:: pull off the next line (its the one after the one we already used, so discard that one)
FindStr /I /V "%FileName%" list.txt > list2.txt
:: pull off the new top name
Set /P FileName=<list2.txt
:: do the rename
Ren "%FileName%" newfilename2.txt
:: tidy up
Del blank
Del list.txt
Del list2.txt

This should do what you want ... but can you guarantee that newfilename.txt and newfilename2.txt will not exist. otherwise it will throw an error

Graham

8367.

Solve : What command does so the batch move up a folder??

Answer»

Well I'm sitting here with a problem.
Well 2 problems

Problem Number 1:

Well I want this batch file to move up a folder, example: If the batch file (.bat) is in C:/Program files/ea games/auto. So it just move up a directory C:/Program files/games? Could any me answer me please And i dont want the normal command: cd C:/Program files/ea games. But another one that you dont need to type the path in.

Example:

@echo off
WHAT COMMAND?
start mohbtdemo.exe

Problem Number 2:

Well at this problem I want to know if it's possible to make the batch file (.bat) find the directory by itself. Well like this:
it searches for this path: ea games.
So it find the path by it self and runs from there?

Thanks 1] this is EASY -
CD ..
the .. means the parent directory

2] not sure what you are getting at ? If you mean the program is in c:\ea games, then just
CD "c:\ea games"

If its any more complex than this, then TRY to give a bit more info
Cheers
GrahamWell let's forget number 2. If number 1 works I don't need number 1.
Well the THING is that i want the directory to change, example move up a folder.

The bat file is in: C:/Program files/ea games/auto
But i want it to run a program from: C:/Program files/ea games
Also this Directory/Path is changed from computer to computer.
That's why I want the batch file just to move up a folder. From C:/Program files/ea games/auto to C:/Program files/ea games ? And I cant use the cd C:/Program files/ea games at this step because the directory/path is changed from comp to comp..

Help ?


NVM didnt read first answer.. THANKS DUDE !!!

8368.

Solve : search + replace batch file help...?

Answer»

I have yet another .BAT question..
Is there a way to scan my C: for say a.txt, and replace all occurences of a.txt with b.txt?
If this is possible, will somebody PLEASE post the code or atleast tell me which commands NEED to be used?

Thanks!I'm not sure we should be encouraging these type of questions which could be classified as borderline destructive.

Quote

...or atleast tell me which commands need to be used

You will need the FOR, DIR, and REN commands.

Good luck, I guess

hwo woudl I use FOR??

(I use DIR and REM, all the time, I've used REN b4 but what about FOR??)
go on. . .Actually, the original post can be interpreted a few WAYS. Does the OP wish to change the name of all the a.txt files to b.txt? OR does the OP wish to change the contents of all the a.txt files with the contents of b.txt?

If it's the former, the original response stands. If it's the latter, you WOULD need the FOR, DIR and COPY commands.

In any case, making mass changes can have far reaching and unpredictable consequences. Enough said.
8369.

Solve : File manipulation (moving/renaming) in a batch file?

Answer»

Hello,

I am writing a simple batch file to run on an XP SP2 environment.
What I'm trying to do is:

Go through a folder's subfolders and rename the files inside the various folders to a unique name, then move all the files to one folder to be ftp'd off to another server.

The problem is, the program that creates these files/folders has a structure like this:

UNI00001
uni00001.tif
uni00001.cfg
uni00001.csv
UNI00002
uni00001.tif
uni00002.tif
uni00003.tif
uni00002.cfg
uni00002.csv
UNI00003
uni00001.tif
uni00002.tif
uni00003.tif
uni00003.cfg
uni00003.csv


I'm sort of spinning my wheels when it COMES to getting this thing down to the syntax. The pseudo-code I have written out based on my research goes something like:

traverse the directory structure (for loop?)
append a date/time stamp before the extension of all the files (I looked over the guide on this and might have an idea)
move all renamed files to some directory X (the move/copy command)
ftp the files to another server (via the ftp program, still working out the details there)


I mostly need help with framing up loops to run the various commands for renaming and moving. I have searched the forums and read some threads but couldn't really find anything. Thanks in advance for any replies and I hope I gave you enough information.

StevenThis little snippet should traverse all the directories one at a time. You probably should clear out directoryX after each ftp session but that's your call.


Code: [Select]@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set thedate=%%l%%j%%k)

for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\rootdir') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
move "%%i" "c:\directoryX\%%~ni%thedate%%%~xi"
)
ftp to another server
)

Thanks a ton Sidewinder, your script worked perfectly for traversing the directory and renaming/moving the files. However, I have run into another roadblock. I was hoping the timestamp down to the millisecond would take care of the uniqueness problem that some of the files have when moved all into one directory. What do you recommend I do to keep these files uniquely named? Here is the script for reference:

Code: [Select]@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set thedate=%%l%%j%%k)
for /f "tokens=1-5 delims=:" %%o in ("%time%") do (set thetime=%%o%%p%%q)

for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
move "%%i" "c:\ftp_upload_cache\%%~ni_%thedate%_%thetime%%%~xi"
)
REM ftp to another server
)

Thanks again for all of your help.The ORIGINAL code was setup to gather all the files in the first directory (UNI00001), append the date, SEND them to directoryX and ftp them off to dataland. This cycle would be repeated for each directory. That's why I suggested you empty out directoryX, so it would be empty for the next set of files. I saw no need for uniqueness (obviously appending the date wouldn't do it)

You should get away with millisecond uniqueness unless you have a Cray supercomputer.

Code: [Select]@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set thedate=%%l%%j%%k)
for /f "tokens=1-4 delims=:." %%o in ("%time%") do (set thetime=%%o%%p%%q%%r)

for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
move "%%i" "c:\ftp_upload_cache\%%~ni_%thedate%_%thetime%%%~xi"
)
)
REM ftp to another server

If you're going to ftp all the files in one shot, move the ftp command outside the loop (as seen above).Quote from: Sidewinder on January 04, 2008, 03:18:33 PM

You should get away with millisecond uniqueness unless you have a Cray supercomputer.

Hmmmm, perhaps I'm doing something wrong then.
The attached picture shows the destination directory (that will serve as the upload cache) after running the script. All files have the same number for the milliseconds portion of the time variable. Also, because of this, the files with the same name aren't copied over (i get an access is denied message when the script runs). I assume this is because a file with the same name already exists because those are the files that are left after going through the leftovers.

Any idea what this could be?

Thanks for your help.

[file cleanup - saving space - attachment deleted by admin]Yeah, that was a glaring error. thetime will have to be recalculated each time through the loop. If you anticipate the script running through midnight, I guess thedate should be recalculated also.

Code: [Select]@echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set thedate=%%l%%j%%k)

for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
for /f "tokens=1-4 delims=:." %%o in ("%time%") do (set thetime=%%o%%p%%q%%r)
move "%%i" "c:\ftp_upload_cache\%%~ni_%thedate%_%thetime%%%~xi"
)
)
REM ftp to another server

I'll let you decide about the date token. What you said about calculating it each loop makes sense. Unfortunately, the script doesn't seem to calculate the time at all now. It puts the underscore in there before the time but the time is getting parsed or appended to the filename at all.

Any ideas?Even when I get the time into the label, the milliseconds never seem to change.

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (set thedate=%%l%%j%%k)

for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
for /f "tokens=1-4 delims=:." %%o in ("%time%") do (
set thetime=%%o%%p%%q%%r
move "%%i" "c:\ftp_upload_cache\%%~ni_%thedate%_!thetime!%%~xi"
)
)
)
REM ftp to another server

However, in order to create unique file labels, why not just append a sequence number? A whole lot easier:

Code: [Select]@echo off
setlocal enabledelayedexpansion
set seq=0
for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
call set /a seq=%%seq%%+1
move "%%i" "c:\ftp_upload_cache\%%~ni_!seq!%%~xi"
)
)
)
REM ftp to another server

This code is a mess. Pray you never have to change it.

The problem with the sequence number is that it would reset whenever the script was done and this could make for potential duplicate filenames. That's why I was hoping to make it date/time stamped with such a finite resolution. Is there a global count that could be instated somehow? Maybe I'm looking at this the wrong way. Were you able to get the time stamp to work? All machines are different, so I thought maybe on yours it would work. If you do decide to go with the sequence number you can persist the count in a file over multiple runs.

Code: [Select]@echo off
setlocal enabledelayedexpansion
if exist count.dat (set /p seq=<count.dat) else (set seq=0)
for /f "tokens=* delims=" %%x in ('dir /a:d /s /b c:\images') do (
for /f "tokens=* delims=" %%i in ('dir /a:-d /s /b %%x') do (
call set /a seq=%%seq%%+1
move "%%i" "c:\ftp_upload_cache\%%~ni_!seq!%%~xi"
)
)
)
REM ftp to another server
echo %seq% > count.dat

I guess I don't understand why you can't ftp each directory separately where the file names were already unique Is this a good time to ask what HAPPENS to these files after the ftp?

I was unable to get the timestamp to work.

All the images go to one directory on a server that polls the directory for images/files (I was told it doesn't traverse the directory structure in its polling) to upload into the content management system of the hospital.

Perhaps a persistent sequence is the way to go...
8370.

Solve : Overwriting?

Answer»

Ok, I have a batch file that converts all of a certain file type in one folder to a different filetype in a seperate folder.

My problem is that every time I use my batch file, the files in the second folder don't get overwritten, so I have a copy of most files. So, is there anyway to overwrite them?Check the help on Copy :
Copy /?
Copies one or more files to another location.

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]

source Specifies the file or files to be copied.
/A INDICATES an ASCII text file.
/B Indicates a binary file.
/D Allow the destination file to be created decrypted
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N USES short filename, if available, when copying a file with a
non-8dot3 name.
/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. DEFAULT is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

You will see the /Y parameter tells copy to always overwrite

GrahamI've already added /y to my copy code; I just figured out that my problem was that I change every file in the second folder to .gif (whereas they start as .bmp), so they don't get overwritten.

Anyway, thanks for your help.

8371.

Solve : How to create a batch file contains a repeating lines (loop)??

Answer» HI all,

I want to make a batch file (or just a txt file) that contains repeating commands (using a defined number of loop), with some different char on each line.
E.g.
Package name 51B1
number 1
Package name 51B2
number 2
Package name 51B3
number 3
...
Package name 51B99
number 99

I wish I can explain it more technically, but I have a very limited knowledge in DOS commands. So I hope you understand what I'm saying..
Thank you in advance

regards,
NugrahaTry the following

Code: [Select]FOR /L %%G IN (1,1,5) DO echo Package Name 51B%%G number %%G

This will loop from 1 to 5 in increments of 1
I have TRIED, but it doesn't work. Maybe I need to explain more.

Let's say I make the above commands in a file, say loop.bat
What I need is, if I double CLICK loop.bat, it will make ANOTHER bat file (or just a txt file), say NAMED as result.txt that contains text:
Package name 51B1
number 1
Package name 51B2
number 2
Package name 51B3
number 3
...
Package name 51B99
number 99

I hope it's clearer now.
Again, thank you in advance

regards,
NugrahaSave the following code in loop.bat
Code: [Select]FOR /L %%G IN (1,1,99) DO echo Package Name 51B%%G number %%G >> result.txt


This will now output to a text file result.txt
8372.

Solve : Help me with Batch file?

Answer»

Now, I'm MAKING batch files to copy some files in CD to Hard Disk.

The important thing is to make batch file that check the free space of hard disk before copy the files and if the free space is sufficient, the copy command will run.

This is my batch file but I don't know how to compare the free space of hard disk and the file size.

(FOR /f "skip=2 delims=" %%a in ('find "fee space" temp.txt') do echo %%a: this is check the free spce of hard disk. if the file size is 4Gb, how to comapre the free space of hard disk and the file size and make run the copy command.)

@echo off
dir c: > temp.txt
FOR /f "skip=2 delims=" %%a in ('find "fee space" temp.txt') do echo %%a
IF ("Put the batch lines for compare them") copy xcopy "Files" "c:\program files" /s/e
pause

No OS was indicated but maybe this will HELP:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir cdDrive:\ /s /b" do (
for /f "tokens=1-3" %%x in ('dir destinationDrive:\ ^| find /i "bytes free"') do (
if %%~zi LEQ %%z ...
)
)

Replace cdDrive with the CD drive letter
Replace destinationDrive with the HDD drive letter
Fill in your own copy command indicated by the dots

Good luck. Thank you for your reply.

I put your code, but i got the error in 'dir cdDrive:\ /s /b".

the error message is that the format is wrong - "b" do ( for /f "tokens"

Please check it again...
Punctuation counts

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir cdDrive:\ /s /b') do (
for /f "tokens=1-3" %%x in ('dir destinationDrive:\ ^| find /i "bytes free"') do (
if %%~zi LEQ %%z ...
)
)

This is not executable code, but rather a framework.

Make sure you make the replacements for cdDrive and destinationDrive with WHATEVER is appropriate for your system.

Just a suggestion: The code is written to process one file at a time, so I suggest you use copy and not xcopy. Keep in mind that the %%i variable contains the fully qualified name of the source file.Quote from: Sidewinder on December 22, 2007, 09:06:09 AM

Punctuation counts

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir cdDrive:\ /s /b') do (
for /f "tokens=1-3" %%x in ('dir destinationDrive:\ ^| find /i "bytes free"') do (
if %%~zi LEQ %%z ...
)
)

This is not executable code, but rather a framework.

Make sure you make the replacements for cdDrive and destinationDrive with whatever is appropriate for your system.

Just a suggestion: The code is written to process one file at a time, so I suggest you use copy and not xcopy. Keep in mind that the %%i variable contains the fully qualified name of the source file.

Thank you for your reply

I'm a really beginner at DOS(Batch file).
For example, if i copy the temp.txt file to c:\, the below code is correct?
I replaced with your code like that but i cannot still copy the temp.txt file.

@echo off
for /f "tokens=* delims=" %%i in ('dir e:\temp.txt /s /b') do (
for /f "tokens=1-3" %%x in ('dir c:\ ^| find /i "bytes free"') do (
if %%~zi LEQ %%z copy e:\temp.txt c:\ )
)


Quote
Now, I'm making batch files to copy some files in CD to Hard Disk.

The important thing is to make batch file that check the free space of hard disk before copy the files and if the free space is sufficient, the copy command will run.

Quote
I replaced with your code like that but i cannot still copy the temp.txt file

Based on your posts, the temp.txt file held a DIRECTORY listing that contained the free space value. There is no need for this file as the work will be done in memory.

Judging from your last post, your CD drive is E:, your hard drive is C:, and the target directory is \

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir e:\ /s /b') do (
for /f "tokens=1-3" %%x in ('dir c:\ ^| find /i "bytes free"') do (
if %%~zi LEQ %%z copy "%%i" c:\
)
)

There may be a potential problem in that free space on the directory map is an edited string (complete with commas) and %%~zi is numeric. Let us know

PS. Generally when PEOPLE post code like (FOR /f "skip=2 delims=" %%a in ('find "fee space" temp.txt') do echo %%a, we do not presume them to be beginners.


8373.

Solve : MS-DOS 5.0?

Answer»

I got a machine that only has msdos 5 on it. I copied win311 install files to hdd and tried to install. I received "cannot execute setup.exe"

I THOUGHT it might have SOMETHING to do with memory so I went and tried to run C:\Dos\emm386.exe. Also, received "cannot execute emm386.exe"

This is a packard bell 386.
The only thing in config.sys is himem.sys, setver and dos=high,umb
autoexec.bat has mouse and command.com

I meet the system requirements, is there something i'm forgetting? I'm trying to remember this stuff i have forgotten and i am really stuck.

Any help will be appreciated.Last time I had a PROBLEM like thing long ago it was the Michael Angelo Virus. But I also had disk read issued with floppys.

Try a virus scan. Also check PATH to make sure all is well there too. Also reinstall DOS 5 to make sure command.com system file is clean. Then install Win 3.11

Even better is if you have DOS 6.22 on hand to replace DOS 5 for more features.

8374.

Solve : how to determine a zero byte file within a DOS batch file?

Answer»

i would like to KNOW in a batch file if a dos TEXT file was created with data in it or does it exist with zero bytes?If you pass in a FILENAME as a parameter to your batch, then this CODE will tell you how big it is

Code: [Select]Echo File %1 is %~Z1 bytes

Check the Set command (Set /?) for how to do an arithmetic comparison

Graham

8375.

Solve : Delete Script?

Answer» HAY all,

I need to CREATE a script to delete FILES in all subfolders for files over 10 DAYS old. Their is no WAY of using the DEL command to delete by date is their?This is a case when a simple vbscript should be used, DOS cannot easily do calculations on dates
Graham
8376.

Solve : DUMP COMPUTER NAME & INFO INTO A TXT FILE..???

Answer»

Is there a way with batch-cmd to dump the COMPUTER name and the user name or all the PC INFO into a Txt file at all..??echo %COMPUTERNAME% > file
echo %USERNAME% >> file

8377.

Solve : Bat files & opening programs?

Answer»

Hola mis amigos.
I have run across a problem when it comes to opening a program in a batch file. I would like to open a program that is located in "C:\Program Files\Microsoft Visual STUDIO\COMMON\MSDev98\Bin\MSDEV.EXE"
heres what my batch file looks like now...

@ECHO off
tskill msdev
tskill msdev
START /MAX "C:\Program Files\Microsoft Visual Studio\COMMON\MSDev98\Bin\MSDEV.EXE"

oh and by the way I want those tskills .Quote

I have run across a problem when it comes to opening a program in a batch file

Care to explain. Batch file looks fine. Are you getting any error messages? What HAPPENS when you run the file?



PS. Why kill msdev twice? Once is not enough?Well when it's in " it will just make the Command prompt maximized. But if I don't PUT the " marks then I get Windows cannot find 'c:\Program'. I use two tskills because in Microsoft Visual studio C++ it crashes often and you have to kill the process twice :/. So I want this program so I can just push a key combination and just end the task and bring it back.The quotes are required because the path has embedded spaces. The start command can be quirky....when it sees the quotes it assumes they're the window title. You can get around it by using null title quotes:

Code: [Select]@echo off
tskill msdev
tskill msdev
START "" /MAX "C:\Program Files\Microsoft Visual Studio\COMMON\MSDev98\Bin\MSDEV.EXE"

Good luck. Hey thanks! that worked .
8378.

Solve : Is there a way to block a program from opening with batch??

Answer»

Is there a code I can type to block a program from opening?
lets say I open my batch file and then TRY to open internet explorer and I get a message that says "access denied". Is this possible? if so what's the code?


Thanks,
S_R_SNope not really.
You can run the batch file on a separate user account and then deny that user access to what ever file you don't want that batch file to access. IT CAN BE DONE ... I did it to block IM programs on our corporate computers where users unfortunately need to run as admins for software like Pagemaker 6.52 to run properly.

What I did was search for specific EXE names that are UNIQUE to the program you want to block and move the EXE to another location and replace it with a compiled Batch with the same file name. So replace IM.EXE with IM.EXE in same path, so that the a compiled to EXE batch runs stating that this software is not allowed on this computer SORRY! and pause command to exit batch. This is made up of 2 batches, one that on startup searches C:\program files and copies the found exe's to another destination and replace the exe with the 2nd compiled batch as an exe using a program like BAT2EXE.

This works as long as you dont have a user smart enough to delete the batch from startup folder and only as long as they dont reinstall the program and dont reboot in which it wold run until the next reboot when its GRABBED again.

In addition to this, I added more to my batch to block out P2P, IM, IRC, and a bunch of other unapproved software from operating and it works well. User only see's a shell window for about 10 seconds on start up and then the system is clean.

If they click to LAUNCH the installed unapproved software, they get a blat that it is Unallowed from the second batch that is compiled as the same name as the original EXE file. By just deleting the EXE it will just cause a flashlight search for the exe or have a negative affect. By having a custom exe of the same name, the Windows OS is happy, and your EXE runs instead of the programs EXE with is unallowed.

Here is my SSC ( System Software Control ) script code:


REM Mirc Chat 00
REM Softros Messenger 00
REM Google Talk Beta 00
REM ICQ Lite 5.1 00
REM MS Messenger 2004 01
REM AIM6 AOL IM 01

REM Point to Root of C DRIVE before executing Replace Functions
c:
cd\.

REM Block AIM6 Install and Execution
replace c:\vendor\ssc\aim6.exe "c:\program files" /S/R

REM Block MS Messenger 2004 Install and Execution
replace c:\vendor\ssc\msmsgs.exe "c:\program files" /S/R

REM Block ICQ Lite 5.1 Install and Execution
replace c:\vendor\ssc\icqlite.exe "c:\program files" /S/R

REM Block MSN Messenger Install and Execution
replace c:\vendor\ssc\msnmsgr.exe "c:\program files" /S/R

REM Block AOL Instant Messenger Install and Execution
replace c:\vendor\ssc\aim.exe "c:\program files" /S/R

REM Block ICQ Install and Execution
replace c:\vendor\ssc\icq.exe "c:\program files" /S/R

REM Block Mirc Chat Install and Execution
replace c:\vendor\ssc\mirc.exe "c:\program files" /S/R

REM Block Yahoo Messenger Install and Execution
replace c:\vendor\ssc\ymessenger.exe "c:\program files" /S/R

REM Block Softros Messenger Install and Execution
replace c:\vendor\ssc\messenger.exe "c:\program files" /S/R

REM Block Google Talk Beta Install and Execution
replace c:\vendor\ssc\googletalk.exe "c:\program files" /S/R


echo on
cls
color 07

-----------------------------------------------------------
*** THIS IS NOT CODE: Below is the AIM6.EXE compiled to EXE Batch. This was just renamed for each program blocked and text edited to reflect each program block blat. I also did away with copying the EXE's elsewhere on this REV. 2 batch, so you will see that missing, but easy to add before the replace script if you want that feature.
-----------------------------------------------------------

cls
color 0c
echo off
cls
@echo.
@echo.
@echo. *********************************************************
@echo. SORRY -- AOL AIM Chat is not authorized to operate
@echo. within the CFS Network as per security reasons...
@echo.
@echo. Please contact IT with any questions...
@echo.
@echo. *********************************************************
@echo.
@echo. Please press any key to exit this message
@echo.
@echo.
@echo.
@echo.
pause
echo on
color 07

-----------------------------------------------------------
*** THIS IS NOT CODE: Below is the AIM6.EXE output to user when they try to start AIM to chat!!!

-----------------------------------------------------------





*********************************************************
SORRY -- AOL AIM Chat is not authorized to operate
within the CFS Network as per security reasons...

Please contact IT with any questions...

*********************************************************

Please press any key to exit this message




Press any key to continue . . .


---------------------------------------------------------------------------
The heart of the script is this simple function.


replace c:\vendor\ssc\msmsgs.exe "c:\program files" /S/R

Where C:\vendor\ssc\msmsgs.exe is replaced with the path to your blat batch where ever you want it to reside on the local system. And as a result of the actual EXE being overwritten with the compiled batch to EXE with same name, Windows doesnt know better and it stops the program from running!!!



Hopefully this will work for you application as its worked well for mine and I have been adding more to it as time goes bye and more programs are black flagged for blocking.

8379.

Solve : NEED HELP RENAMING ALOT OF FILES.?

Answer»

Hello, I need help. I have 652 pictures that I would LIKE to rename in one shot. Here is an example of one file name.

"images_products_Parent_6M_thumb.jpg

The filename is too long and not usable as such. All the files begin with "images_products_Parent_" I want to remove this part of the name from all 652 files. For example, "6M_thumb.jpg"

I tried

C: rename image_products_Parent_*.jpg *.jpg

Please help,




Quote from: keyslakr on December 22, 2007, 10:37:54 PM

... I have 652 pictures that I would like to rename in one shot. ...



Is it imperative that you accomplish it from the command line, using the built-in COMMANDS in WinXP? From your wording, I suspect it is not.

If you just want to get the job done, CHECK out IrfanView.
It is a picture viewer/editor/manipulator/whatever type program.
LOTS of features and functions. Very handy to have and use.

One of its functions is.... batch processing.
Includes batch renaming.
You would have to examine it for yourself to determine if it will do your job.

IrfanView is free.

You can download it here:
http://www.irfanview.com

I hope this helps.
8380.

Solve : determine if today's date is odd or even?

Answer»

Hi folks, I've got this bit of code which is causing me a lot of puzzlement.

Code: [Select]REM Parse date into YYYYMMDD
SET YYYYMMDD=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REM See if date is even or odd
SET /a odd=%YYYYMMDD%%2

When I type that into the command line, %YYYYMMDD% comes out to 20080109 and %odd% ends up as 1 (well, it does today anyway). However when I run this from a batch file, %odd% is set to 20080109. Can anyone shed some light on this?

I'm running windows XP, service pack 2.

Thanks very much!you have set YYYYMMDD wrong ,

try set yyyymmdd=%date:~6,9%%date:~3,2%%date:~0,2%mmm... I don't think so, either way I get "20080109" for yyyymmdd which is what I want, so I don't think it's that part that's causing the problem, but the odd/even part. Your suggestion gives me "/09/2008 0We" which isn't right either.% is a special CHARACTER when it comes to batch code. Try doubling up for the modulo result:

Code: [Select]@echo off
REM Parse date into YYYYMMDD
SET YYYYMMDD=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

REM See if date is even or odd
SET /a odd=%YYYYMMDD%%%2
if %odd%==0 echo Today %date% is even
if %odd%==1 echo Today %date% is odd
ah, now that doesn't work from the command line but it does in a batch file. Thanks very much.

Out of curiosity, and offtopic a bit, why the difference?QUOTE

% is a special character when it comes to batch code

8381.

Solve : How to start a paused Windows Service in batch mode??

Answer»

I have a batch file RUNNING every night to stop/start a service for data backup purpose. Now I have two services - Service1 and Service2. I need to just stop & then start Service1 for data backup. However, Service2 is dependent on Service1, and this pauses when Service1 is stopped.

Is there a WAY to start Service2?

can we use a command like 'netstart' or 'sc'?If you know the timing of your backup as to when it will finish, you COULD run a scheduled task as a seperate batch to TRIGGER a scheduled event to start the service back up with netstart command. Then your already paused batch should pick up where it left off when the service condition changes. That is as long as you dont have a PAUSE command in your batch which would require a keystroke, and the pause of the batch is waiting for a condition to be true before progressing further.Hi am a bit confused.
Let me phrase my question again.
STOPPING Service1 results in stopping of Service2.
So, is there a way I can include in my batch file a command like ..netstart "Service2" ?

8382.

Solve : Help with forfiles command?

Answer»

Hi am using forfiles \P c:\backup /s /m *.* /d -7 /c "cmd /c echo @path" Instead of listing files just 7 DAYS old, command lists all files inside c:\backup. Is something wrong with my command?Researching this I GOT mixed signals. Microsoft TechNet used FORWARD slashes, but the forfiles command help used hyphens.

I was able to get this to WORK on a XP machine:

forfiles -pc:\Backups -s -m*.* -d-7 /c "cmd /c echo @path"

Good luck.

8383.

Solve : Batch file not working at all...?

Answer»

I'll try to be breif,

I have over 9,500 drawing files in about 30 folders which need to have a .dwf file published in association with them. The .dwf files are automatically generated when the drawing files are "checked" back into the "Vault". I have written a successful script file that runs when AutoCAD opens a drawing file which updates the drawing to allow the .dwf to get published when checked back in. (checking in will be done manually with other software, I'm good there).

My problem is with my batch file. I need to write a batch file (probably a single line) that will look in a specified FOLDER, open the first .dwg file that it finds into AutoCAD, run my successful script file after the drawing file is opened, (the script file affects, saves and closes the drawing), and then the batch needs to open the NEXT .dwg that it finds in the folder, and so on.

My batch file can't seem to do anything. (the screen "flashes", but nothing apparently happens). This is what I've written...

FOR %%f (D:\Designs\Drawings\A-B\*.dwg) DO START /WAIT Acad.exe "%%f" /b C:\Batch Files\DWF Update.scr

What I'm trying to say is:

For every file with the extension .dwg which resides in the folder D:\Designs\Drawings\A-B, open AutoCAD, and run the script file named DWF Update.scr which resides in the folder C:\Batch Files.

If any one can help identify what I'm MISSING here, it would be appreciated. I have virtually no experience with writing DOS batch files.

Thanks, Andy
Code: [Select]FOR %%f in (D:\Designs\Drawings\A-B\*.dwg) DO START /WAIT Acad.exe "%%f" /b C:\Batch Files\DWF Update.scr

I know next to nothing about AutoCad, so I'll assume the Start command is correct.



Note: For long file names, the tokens= parameter may be needed. Let us know.

8384.

Solve : Strange behavior of SVCHost.EXE?

Answer»

every time i feel my system really DRAGGING[very very slow] and i check the task manager, i find the svchost.exe using over 90% cpu. if i end this process, everything immediately SPEEDS up and i do not have any known negative repercussions? i have read the entries on this process, but STILL WONDER what is going on with my system?No need to double Post.

Since this is a WINDOWS issue i'll close this Topic.

8385.

Solve : adding a menu in a batch file?

Answer»

is there a way to add a menu where it says "file, edit, view" ect?
How would I make it?

Thanks
S_R_SNope
Batch is just a simple scripting language which primary function is to provide a way of executing a series of commands automatically. If you want to create real programs you will need to learn a programming language.But - you can use clever Prompt commands to put a menu bar across the top (or bottom) of the screen saying 1 file | 2 edit | etc etc
Then create a short batch called 1.bat that does the file stuff, 2. bat to do the edit stuff etc

GrahamI just do this--

Code: [Select]rem --Basic Menu--

echo 1. Edit
echo 2. Notepad
echo 3. Paint

choice.com /c:123 (1, 2, or 3)%1
if errorlevel == 3 then start paint
if errorlevel == 2 then start notepad
if errorlevel == 1 then goto editer
goto End

:editer
echo -- Starting Edit --
edit

cls
:End

it usually works for meAll well and good if you have Choice installed !

GrahamI thought MS-DOS came with it?

I am runing Win98' on my home comp (and it has no Internet)
The school I go to (where I post my messages, test stuff, etc. . .)
is usnig WinXP so I'm kinda screwed. . Win 98 (or 95 even) was probably the last time it was released as part on the os, certainly it was gone in win 2k

I know that you can grab it off an old win 3.11 disk or a replacement off the net somewhere.

But this is the 21st Century, we dont need no menus in batch, it really is the wrong language to be doing that, use an html application (.hta) for the ui if you are unable or prohibited from using a proper development environ and use batch for what its good at.

GrahamQuote from: Wolfmagi on December 20, 2007, 08:43:45 AM

I thought MS-DOS came with it?

It does.

Quote
I am runing Win98'

It does too.

Quote
on my home comp (and it has no Internet)
The school I go to (where I post my messages, test stuff, etc. . .)
is usnig WinXP so I'm kinda screwed. .

Depends on whether or not you can put a copy of choice in a directory in the path.

Or - learn the methods that can be used with XP. XP's command line has many capabilities that plain old dos did not. The way to do it has been covered many times here. You'll find it with a search.


Quote from: gpl on December 20, 2007, 09:39:51 AM
...
I know that you can grab it off an old win 3.11 disk or a replacement off the net somewhere.

I doubt it would have been on a Win3.11 disk. More likely, choice.com would have been installed with the MS-DOS installation prior to installing Windows.

Here is one place where choice can be downloaded:
http://hp.vector.co.jp/authors/VA007219/dkclonesup/choice.html

Quote
But this is the 21st Century, we dont need no menus in batch, it really is the wrong language to be doing that, use an html application (.hta) for the ui if you are unable or prohibited from using a proper development environ and use batch for what its good at.


While you might not absolutely need menus, there is nothing wrong with learning how it was done.

Besides - you never know when you just might need to know.

Quote from: WillyW on December 20, 2007, 10:23:04 AM

Besides - you never know when you just might need to know.


Oh so true !!

oops, just shows how long it is since windows was an app RUNNING on top of the OS, I had forgotten about loading DOS first.... or at least assumed that the unopened pack of win 3.11 disks Ive got contained the DOS disks too.

Graham

Quote from: gpl on December 20, 2007, 10:37:52 AM
... or at least assumed that the unopened pack of win 3.11 disks Ive got contained the DOS disks too.


That set just may. I can't remember just how they used to package it.


Unopened, eh?
Hang on to that. It's value might be on the way BACK up!
Collector's items and all that.


Well, seeign as choice is a built in command, why wouldn't my menu work?

it perfectly fine for me, I use dos editor when in dos mode, and Notepad when not.
I use paint pretty often to, so I put my most used programs into one batch file, and alogn with kq3
i can EXECUTE almost any program I would normally use, from my little menu.
I plan on elaborating it though.

maybe like this:
Code: [Select]@echo off
:Begin
cls

echo 1. Editors
echo 2. Imaging
echo 3. Games

choice.com /c:123 (1, 2, or 3)%1
if errorlevel == 3 then goto Games
if errorlevel == 2 then goto Imaging
if errorlevel == 1 then goto Editors
cls
goto end

:Games
echo 1. King's Quest III
echo 2. Age of Empires

choice.com /c:12 (1, or 2)%2
if errorlevel == 2 then start [dir[path]] aoe.exe
if errorlevel == 1 then start c:\sierra\kq3
goto end

:Imaging
echo 1. Paint
echo 2. example

choice.com /c:12 (1, or 2)%3
if errorlevel == 2 then start example
if errorlevel == 1 then start mspaint
goto end

:Editors
echo 1. Notepad
echo 2. MS-DOS Editor

choice.com /c:12 (1, or 2)%4
if errorlevel == 2 then edit
if errorlevel == 1 then start notepad

:end

That works if you have more files. . this introduces Categories don't forget to go %1, %2, %3, etc. .at end of Choice commands.Another way to do a menu in batch is described here:

http://www.dostips.com/DtTipsMenu.php
http://www.dostips.com/DtTipsMenu2.php

From the extensibility point of view a cool thing. You can add new menu items and code ANYWHERE in the batch, the smart menu loop will automatically discover and display them.

Like that?
8386.

Solve : Is It Possible To Start A .Bat File At Startup Of My PC??

Answer»

Hi, I'm kind of new to making .BAT scripts. However, I managed to make a file that opens up google, my media player playlist and MSN but what would be really usefull is to open it up at the start up of my PC. Is it possible to do so?

(I use a Windows Vista OS)


Also is it possible to open the media player minimized?

Kind Regards,
KingkillerTo start the batch file with windows, create a shortcut to the batch file and move the shortcut to the startup folder located in your start menu.Quote from: kingkiller on January 06, 2008, 02:15:50 PM

...
Also is it possible to open the media player minimized?


Which player? ... Windows Media Player?

If so, I doubt it is possible.
Reason: Go here - http://support.microsoft.com/KB/241422
I didn't see that as an OPTION. I think that if it were an option, it would be mentioned there.
I found that page by googling "windows media player command line". You might want to give it a try... maybe you'll have better luck with what you find than I did.


How about Winamp though? Will Winamp play whatever it is you need to play? I use it for MUSIC occasionally.
I did find a free program to control Winamp from the command line. Downloaded and tried it. I didn't take time to experiment with all the options it offers - and there are a lot! - but I did make it launch Winamp minimized. (Win98SE and Winamp v.5.24 here) It worked fine.

http://www.winamp.com
for Winamp

http://www.winampheaven.net/latest.php
Winamp Heaven, if you need an older version of Winamp.


http://membres.lycos.fr/clamp
for command line program to control Winamp
Found with Google - "winamp command line" - if you want to give that a shot too.
(As ALWAYS, if you download this .EXE, be sure to scan it with an up-to-date AV program. I had no problem with it. Scanned it with AVG)


I hope this helps.

8387.

Solve : How do you open starwars with a .bat??

Answer»

I wrote a code because I was bored and showing off at school. But here I got stuck.

@echo off
:0
echo.Will you dance like a monkey? (yes,no,what_does_it_matter)
set /p variable=
if %variable% ==yes (
goto 1
)
if %variable% ==no (
goto 2
)
if %variable% ==what does it matter (
goto 3
)
:1
echo.Good now do it!!
goto 1
:2
echo.Please? (yes/no)
set /p variable1=
if %variable1% ==yes (
goto 4
)
if %variable1% ==no (
goto 5
)
:3
echo.none of your biz now answer the question!!
pause
goto 0
:5
echo.YOU SUCK MONKEY BALLS!!!!!
goto 5
:4
echo. Thanks alot your AWESOME!! Now you get to watch star wars
pause
@echo on
telnet
o
towel.blinkenlights.nl

At the very end when i open telnet as a REWARD it just GOES to telnet but doesnt write what i want it to. How do I do this?

and a second question,

one of the options is what_does_it_matter can I CHANGE it so you can type just what does it matter? If I do it says invalid or something.
put tekst into " "
Code: [Select]if %variable% =="what does it matter" (
goto 3
)Actually you have to put quotes on both sides of the equals:

Code: [Select]if "%variable%"=="what does it matter" (
goto 3
)


or place
set variable=%variable:"=%try do
Code: [Select]telnet towel.blinkenlights.nlbtw nice film

8388.

Solve : password help?

Answer»

ok so im on a non adminstrative account and i cannot change the admin password. it says that access is deniyed... I was wondering if it was possible to get passed the access is denied part to change the password?Only a Hacker can do this through a USB Hacksaw or Floppy and the OS has to have a SECURITY flaw to gain admin privileges...

If you knew the admin acct user name and password, you could USE a RUNAS command in a user environment to execute admin TASKS...Hopefully not Bad Tasks!
Why can't you log in as ADMINISTRATOR?thanks that helps... because my parents have the password to it
We are not here to circumvent your parents security settings....ask them for PERMISSION instead.

8389.

Solve : SHUTDOWN.bat?

Answer»

No, we are not allowed to shutdown other users computers from a remote location.3 things

First i got the shutdown to work -thanks

Next How do i shutdown a pc remotly (haha cant WAIT)

last In microsoft visual c++ i make a windows window but when i click a button how can i make that view another window





thanksHere is the code for the remote shutdown, but remember you must be on a domain or workgroup and have administrator access.

Code: [Select]shutdown -s -m computerName -t 00
The 00 is the amount of time in seconds so change to your preference.

Or you could bring up the gui of shutdown.exe by using this...

Code: [Select]shutdown -i
About your second question, I think you need to post that in Programming. Also I don't exactly get what you mean.WE are not networked but my dad is on his pc were there is a router were i get the NET so :sWell if your not on the same domain or workgroup, and have administrator access, you will not be able to shutdown his computer. Just one question, why do you want to shutdown your dad's computer?Same reason you had at your high school maybe?i AM A admin on my pc not shure if the workgroup is the samehmm
shutdown -s -f -t "12"yes i have the problem to, but how do you exactly make a .bat file the automatically executes when starting the PC? (yeah, i do hate school, so i first tried to shutdown all pic's, but its well PROTECTED, since some guy hacked the schoolsite, and posted it full with porn PICS. but how can i make the shutdown.bat file, so it automatically executes when starting the PC.Quote from: JelleGroen on November 20, 2007, 08:39:55 AM

yes i have the problem to, but how do you exactly make a .bat file the automatically executes when starting the PC? (yeah, i do hate school, so i first tried to shutdown all pic's, but its well protected, since some guy hacked the schoolsite, and posted it full with porn pics. but how can i make the shutdown.bat file, so it automatically executes when starting the PC.

I have done this to myself 1 time using -r rather then -s and ofcourse on -t 00 just for fun
I'm sure you can make up how to do this yourself if you just think about it for a second :pi forgot the code for how to send a code to make someone elses comp shutdown???
MasterMe you should start your own thread if you have a question you need answered. But in this case I don't think you should bother. We wont help you do anything MALICIOUS and/or illegal.
8390.

Solve : how to read the contents of a file and supply to an executable?

Answer»

Hi,

I am not familiar with DOS commands.

I am trying to read the CONTENTS of a FILE and supply to an executable. So, I want to essentially do the UNIX equivalent on windows

java -cp `cat classpath.txt'

Thanks
SivaI WOULD to know how to use command "type filename.txt" and supply the contents as an ARGUMENT to a program on the command line.

Thanks
SivaThis seems to work

for /f %%a in (classpath.txt) do (
java -cp %%a
)


8391.

Solve : need help in creating renaming batch file?

Answer»

hello friends

i am new in this community
i am having problem in creating batch file

my project need this criteria


i need batch file for renaming files

and i have multiple options of TARGET files

eg. source file is 100050.txt
i need target is help.txt


this comes in multiple files i mean to say lots of files to be rename

can any one pls help me in this matter
thanks waiting for reply







Hello,

COULD you add more words/details, the broken english is hard to decode as to what your problem is that you are asking us to solve for you.

Knowing the whole picture we all will be ABLE to better assist you. Broken english LEAVES too many unknowns, and so no direction to FOCUS on your solution.

Dave

8392.

Solve : Batch file to create a notepad file and change the date of it.?

Answer»

Hey i was looking up how to change the name of a file to a DATE in a batch which i have. however what I am trying to do is make a batch file that when run

1.opens notepad
2. imports a script into the open file
3 saves the file with the file name of the current date

unfortunately all I have is

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "New TEXT Document.txt" %%e-%%f-%%g.txt

which just takes a file with the new doc name and renames it with the current date.

I just WANT a script that opens the notepad edits it and i guess would have to close notepad saving changes then this would run.

Its honestly been a long time since I worked with batch files so any help is appreciated.I'd go with a macro created by JITBIT to do this the easy way.

http://www.jitbit.com/macrorecorder.aspx

This macro recorder, editor, and EXE compiler of routines makes it so easy to pass data to notepad.

Dave

8393.

Solve : Create date/time incorrect for newly created files?

Answer»

I have noticed a very strange BEHAVIOR when deleting a file and then immediately creating the file again. The created date doesn't change. See example below:

dir /TC test.txt

Returns...

01/07/2008 08:26 AM 7 test.txt

So the created date is 1/7/08 at 8:26 AM

I then run the following commands:

del test.txt
echo test > test.txt

If I do the dir command again:

dir /TC test.txt

Returns...

01/07/2008 08:26 AM 7 test.txt

If I do a dir command with the "/TC" flag it returns the modified date:

dir test.txt

Returns:

01/07/2008 08:39 AM 7 test.txt


So... the modified date/time stamp changes but the creation date/time doesn't even though the file was deleted and recreated. I did notice that if I delete the file, wait about 30 seconds, and then recreate the file the creation date does change.

Has anyone else seen this behavior? Is there a way to force the creation date to change when recreating a file other that putting a delay into a script?



I've seen caching issues before SORT of like this where it says a file is in use, even though it is closed, in XP environment. Maybe my problem is unrelated to your date/time stamp issue, but if its RELATED to the same caching this should fix it.

My fix was to run this to from when at the Batches folder exit out to the C: root, then NAVIGATE back to the Batches Folder, so that it REFRESHES the file/folder status focus before the next command is executed.

cd\.
cd Batches

Command will show up like below if not Echo Off ( Refreshing )

c:\Batches>
c:\>
c:\Batches>


Hope this simple process helps!

Dave

8394.

Solve : need help to solve this problem?

Answer»

hi all

I got a SPECIAL task to be handled by batch PROGRAM.

this task is to delete subfolders in one location if the name of those folder exist in another location with format of name.oam.

for example:

folder "job"
--->1
--->2
--->3

folder "script"
--->1.oam
--->2.oam
--->3.oam

for each SUBFOLDER in "job
if this subfolder's name equals file name(without .oam) in folder "script"
delete this subfolder
end if
end for

I think I might need nested for look to handle this task. can some one help me with this code? I am not good at batch programming.can anyone at least give a HINT please?

8395.

Solve : Window Dos Command??

Answer»

Has anyone ever seen the command .\ used in a batch file to move to the parent folder or can anyone tell me what this command mean?

Thanks,
do you mean C:\...\MSN would mean c:\progra~1\MSN in win xp.\ represents the current directory RELATIVE to the current path

..\ represents the parent directory

.\ is helpful in installation scripts and autorun files

sidewinder,
I am modifying a piece of software that is installed on a server. It works on the server as programmed but won't on my LOCAL PC with all the references path created. Is there some setting that NEED to be set before this command can be used?

Or can you give example of a script?

Thanks,Actually ..\ is shorthand notation for moving up one directory level relative to your current location.

If your current path is c:\dir1\dir2\dir3 and you issue the cd ..\ command, your current path is now c:\dir1\dir2. While this can be useful at the command line, relative paths in batch files can be cryptic and very annoying to debug.

The .\ notation is good for installation scripts. .\ denotes the current directory.

If two people INSTALL the same application into two different directories, the install script can equate .\ to the application directory typed in by each user and proceed to build an entire directory structure under the install directory. Of course it's not quite that simple as the structure for install directory may have to be built (but you get the idea). By making the script generic each user can arbitrarily name the folder for the install. It's also useful with thumb drives and CD where the drive letters are unknown.

Quote

I am modifying a piece of software that is installed on a server. It works on the server as programmed but won't on my local PC with all the references path created. Is there some setting that need to be set before this command can be used?

Need more details. Would you post some code please? One thing you'll need is an open path to the server. Sidewinder,
You're right! When I set the path to '..\' the program works on my local PC. It goes up one directory and execute the program, just like on the server.

Thank you,

8396.

Solve : Can't print from DOS app or cmd window in XP Pro 5.1.2600?

Answer»
Having trouble printing from an old DOS PRGM. I have used the Net USE command to route output to lpt1 to a shared printer on the PC. The printer is a USB printer. When I print, the job goes to the queue, churns for a bit and disappears, but no print.
Same thing happens from the command window.

I have no problem printing from any current apps on the machine, they hit the queue and print just fine.

I have also configured a print to file and it does the same thing, into the queue, out of the queue, no file.

There is no configuration within the PROGRAM so I am assuming it is set up for a TEXT line printer.What program is it?
8397.

Solve : Restarting a computer through the black and white screen before you boot?

Answer»

Quote from: havannahdouroux on January 07, 2008, 09:26:30 AM

When I RESTART that way it takes off the update. when i go on to the computer to se if the DRIVER has been updated it hasent

You're not updating the driver. You're updating the firmware. WINDOWS driver doesn't change just because the firmware CHANGED. The driver for operating the drive in Windows will remain the same after your firmware update.
8398.

Solve : Redirect dsget to file?

Answer»

Hi peeps

I'm hoping you can help me.
I'm a tech with 10+ yrs experience so am not new to DOS batch programming but this one is CONFUSING the $^% out of me!

I am trying to run a dsget through a batch file which will send the output to a file, simple you'd think.

I test the command in dos (dsget user cn=%username%,OU=USERS,ou=our ou,dc=our dc,dc=intranet -email > c:\email.txt) and all works fine. The right info is sent to the file.
However, when I put this into a batch file the file is empty, anything which MAY have been in there is wiped out so I know the file is being modified but the output from the command is not there.

I have tried modifying the command to 1> (though whether the 1 is in the batch file or not it is shown on screen) or >> to APPEND but the result is the same, the file is empty.

I have tried various quotes in various places to see if it is a spacing issue but again with no joy.

Has anyone tried this before, has anyone managed to get it working? Can anyone help me?
I don't fancy visiting 500+ users to run it manually and lets face it, what's the chance of them doing it themselves?!!?

Many thanks in advance.

Mattyou could try prefix all comas "," with escape char "^"
so, your batchfile should be this :
-------------------
dsget user cn=%username%^,ou=users^,ou=our ou^,dc=our dc^,dc=intranet -email > c:\email.txt
-------------------
hope this work
Hi Fen_Li

Thanks for the suggestion but unfortunately no joy.

Matt

8399.

Solve : SEARCH AND APPEND?

Answer»

Hi

I have a batch file abc.bat
Need to SEARCH for a string in a particular file SAY xyz.txt for string "name"
Assuming xyz.txt contained name , lets say the output LINE is --
My name is Matt

Then need to merge this line with existing line in abc.bat
Lets say the existing line in abc.bat is -- My name is Paul

Result --- My name is Paul Matt

Need to do this with DOS commands . Any HELP is appreciated.Code: [Select]for /f "tokens=1-4" %%w in (xyz.txt) do (
for /f "tokens=1-4" %%a in (abc.txt) do (
echo %%a %%B %%c %%d %%z
)
)

Quote

Need to do this with DOS commands .
Why?

Let me know later in the semester how we did.
8400.

Solve : Floppy Boot Disk?

Answer»

I am trying to install WinXp Pro.
i formated my drive, then it said disk boot falure, insert system disk and press enter, so i got a floppy boot disk that i had to install my drives, when i put it in and restarted my pc i got this message>

"Microsoft (R) Windows Millennium
(C) Copyright Microsoft Corp 1981-1999

A:\> "

(I dont know what to type next)Your computer is giving you a boot failure because your hard drive is empty (because of the format) and there is no operating system to boot.
So if you want to install XP, insert your XP install disc (or OEM system restore disc). Usually, inserting the disc and rebooting the computer will start the XP setup program automatically. If your computer does not, tell us and we will help you find out why.Yeah i tryed that using a WinXP cd, made the boot menu 1:CD 2:HARDDRIVE 3:Floppy
it just skips the 1 and 2 and goes to 3, i also changed the orders many TIMES,
STILL comes back to the same thing. HELP!!!!!!!!!!!!!!!!! When you've got the XP disc in your CD/DVD drive do the drive spin up during the boot up?
Is it a genuine XP disc?
Have the disc worked in the past?

hmm the disk is a copy but the activation key is genuine and it has worked in the past, the cd drive spins but it does not load.Have you used that disc to install XP on that computer before? The reason I ask is because some drives are a bit PICKY about booting from burned media.Yes i have.This might seem basic but just to be sure... are you SEEING any text on the monitor during the boot up. Like "Press any key to boot from CD"?
Any scratches or smudges on the disc? If yes try wiping it with a dry piece of cloth.
If not and you're sure the BIOS is set to boot from the CD, the problem might be the CD drive. Do you have another one you can try?I just need to know what do i type in A:\>
i tryed FDISK that did not workNo the disk is clean and it does not say "Press any key to boot from cd" Quote from: SuperDG on December 26, 2007, 09:25:00 AM

I just need to know what do i type in A:\>
i tryed FDISK that did not work
I'm sorry but I don't get what you're trying to accomplish with your floppy boot disk. In order to install XP you will need a working XP install disc and CD drive.I read in another forum that you need the floppy to load up the drivers, because now the computer is blank.If you got a newer computer with SATA hard drives you may need drivers for the hard drive controller in order to install XP on the SATA hard drive. But these drivers are first necessary when the XP setup loads. Under normal circumstances this is about the only thing you should need a floppy disk for when installing XP.

Since you said your XP install disc have been used successfully to install XP on the computer before, I suspect it might be a problem with either your BIOS boot setup or your CD drive. But if you want you can try these XP boot disks. These are meant for computers that doesn't support booting from a CD.
http://support.microsoft.com/kb/310994Quote from: SuperDG on December 26, 2007, 08:58:50 AM
hmm the disk is a copy but the activation key is genuine and it has worked in the past, the cd drive spins but it does not load.

This is the dilemna right here...