English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

my command is in a batch file.It is- for /f %%i in (D:\Storage\Links\Control Panel\Restore\erase.txt) do @erase %%i- I have a list of destinations for deletion in "erase.txt".1 question is how can I get this same batch file to do more than 1 command in the same .txt file.How it is now all items in erase.txt would follow the Erase command.Problem is I want to have only 1 batch file and 1 .txt file with different commands.Second problem is how in the world do you use spaces in the txt file.for example:Control Panel has 1 space.Apparently using " at beginning and end of command doesnt work.I tried putting all names in DOS form but it seems some names of directories dont have a dos form.Kinda odd,its seems only newer files dont have one even after reboot.Im also having the same problem with the batch file destination- D:\Storage\Links\Control Panel\Restore\erase.txt-spaces wont work and cant use "" so how can I do this when some names have no DOS form. Thanks alot if you can help

2007-01-16 13:12:44 · 3 answers · asked by Anonymous in Computers & Internet Software

3 answers

There's a lot to do here. You're using the "for /f" command to parse the lines in your "erase.txt" file and passing each individual line as an input to the "erase" command.

Question 1) How can I get this same batch file to do more than 1 command in the same .txt file

The text file is only a way to provide input to your batch file. The batch file is what executes commands. So, you actually cannot do any command IN the text file. The text file provides the data that the batch file acts upon.

That's the whole purpose of the "For .. Do" commands. It's basically saying .. "FOR every line of text in a file DO this ...".

If you want to do more things, then you will need to add more commands to your batch file.

Question 2) How do you use spaces in the text file.
If you have spaces in any of the individual lines of the input file, then they are automatically treated as variable delimiters. You will have to use one of the command line parameters of the "FOR" command that allows you to use the entire line of text as one variable.

Here's a quick example of how it works,
Go to a DOS prompt and CD to the root of your C: drive
Then execute on the commandline the following

for /f %i in ('dir /ad /b') do @echo %i

This is using the lines of output from a dos command ('dir /ad /b') just like the lines of an input file, like your erase.txt. What this shows is how things get broken up. If you have a standard windows installation, then you should have a "Program Files" directory at the root of c:. But the output on the screen from that last command only shows "Program" because it took the first part of "Program Files" (referred to as a 'token') and put it into the %i variable and left the rest alone because it thought it should. Here's how to fix that,

for /f "tokens=*" %i in ('dir /ad /b') do @echo %i
This will take ALL the input from a line and treat it as one token. So the output should include a full directory listing, even those with spaces.

Question 3) Some names of directories don't have a dos form.
If you are referring to the old 8.3 DOS naming standard, then I think that everything still has DOS names on Microsoft installations. Here's a way to check.

Go to a DOS prompt, change into the directory where you want to see the 8.3 names for some sub-directories, then type the following command,

dir /ad /x

This will list the directories (/ad) and show their short names (/x) of any non-8.3 named directories in the 4th column of output. If the parts of the 4th column are blank, it's because the directory name is already 8 characters or less.

Question 4) Same problem with the batch file destination
I would imagine if you're using the path as stated in your question, that you might be seeing an error like "The system cannot find the file D:\Storage\Links\Control."

That's because it's not properly parsing the space in the directory name, as you have guessed, and it thinks that there is a file called "control" under D:\storage\links

If you try to put quotes around the path like ("D:\Storage\Links\Control Panel\Restore\erase.txt"), then you'll get another error for the same reason.

You will need to use the short names in the path. Here's how I tested it,

I created a file called "blah.txt" under "c:\program files". The blah.txt file just has a few lines of text.

Using the following command just gives me an error,
for /f %i in ("c:\program files\blah.txt") do @echo %i

If I do a "dir /ad /x" on the C: drive, then I find that "program files" is also "progra~1", so I use this command instead,
for /f %i in (c:\progra~1\blah.txt) do @echo %i

And the lines of text in the blah.txt file are echoed to the screen.

Hope this helps.

2007-01-20 08:20:05 · answer #1 · answered by Kevin 7 · 5 0

Get your self a replica of OphCrack. Burn it to a CD. Boot the laptop off the CD. it would want to grant you the administrator password on the laptop. many cases situations it would want to grant you the community administrator's password in the journey that they have got logged on there. get rid of the CD and reboot again. Log in as administrator, bypass to crew coverage and re-enable the command instantaneous. yet you likely did no longer listen this from me. My interest ideal it truly is to reply on your questions, no longer come to a call even with the reality that once you've a reliable rationalization for it or no longer.

2016-11-24 22:16:11 · answer #2 · answered by ? 4 · 0 0

I answered this in the other question you asked about this.

2007-01-16 13:20:05 · answer #3 · answered by davidinark 5 · 0 3

fedest.com, questions and answers