Problems with batch file under XP only


S

Simon Hawking

I need help with an urgent problem.

We have recently migrated from NT to XP pro. We have since found that
several batch files we use no longer run under XP - yet the few remaining NT
machines work fine.

The problem is that the batch files make use of findstr to locate files
based on a keyword contained in some files, and the rest of the batch moves
the files as appropriate.

Example of code (repeated in batch file for each ID in numerical order):

ECHO PROCESSING... Searching for ID E000000
cd \
cd L:\journa~1\Bankma~1\E000000*
findstr /i /m /c:"E000000 " l:\journa~1\unknow~1\ej*.* >
c:\temp\Bankma~1.tmp
FOR /F "DELIMS=" %%F IN (c:\temp\Bankma~1.tmp) DO (MOVE %%F L:)
ECHO Search and process for ID E000000 completed.


I thought it was a problem with commands used, yet when doing a search from
within windows, XP is unable to find these files also - even though I know
they are there.

I was thinking that maybe find and/or findstr need to run in compatibility
for NT - yet this cannot be changes as they are core XP files.

Also, changes need to be implemented across all XP systems, so if this is
possible from the server - please advise.

I can see the files fine.

The attributes to the files have not been changed, and are located on the
server.

The only thing I can narrow down to is that XP cannot perform searches the
same way that NT does. So I need to figure out why, or how to get findstr to
run in NT compatibility (unless there's an easier way).



Help appreciated.
 
Ad

Advertisements

X

Xlnt

Simon Hawking said:
I need help with an urgent problem.

We have recently migrated from NT to XP pro. We have since found that
several batch files we use no longer run under XP - yet the few remaining
NT machines work fine.

The problem is that the batch files make use of findstr to locate files
based on a keyword contained in some files, and the rest of the batch
moves the files as appropriate.

Example of code (repeated in batch file for each ID in numerical order):

ECHO PROCESSING... Searching for ID E000000
cd \
cd L:\journa~1\Bankma~1\E000000*

What should these two lines do?
findstr /i /m /c:"E000000 " l:\journa~1\unknow~1\ej*.* >
c:\temp\Bankma~1.tmp

You can use long names too. If the filenames contain spaces, use double
quotes around them.
FOR /F "DELIMS=" %%F IN (c:\temp\Bankma~1.tmp) DO (MOVE %%F L:)

There's no need for a temp file. Use the last command without the redirect
as a quoted command in the for statement.
FOR /F "DELIMS=" %%F IN ('findstr /i /m /c:"E000000 " l:\journa~1\unknow~1\ej*.*') DO (MOVE %%F L:)
ECHO Search and process for ID E000000 completed.

All should work fine, however, you could make the script a little shorter as
mentioned.
I thought it was a problem with commands used, yet when doing a search
from within windows, XP is unable to find these files also - even though I
know they are there.

Does the script give any error message or something?

What happens if you execute the commands manually and seperately in a
console window? Don't forget to use %F instead of %%F then. If you still
want to use the temp file, check the contents of it.
I was thinking that maybe find and/or findstr need to run in compatibility
for NT - yet this cannot be changes as they are core XP files.

The only thing I can narrow down to is that XP cannot perform searches the
same way that NT does. So I need to figure out why, or how to get findstr
to run in NT compatibility (unless there's an easier way).

You shouldn't need to do this.

Xlnt
 
S

Simon Hawking

Xlnt said:
What should these two lines do?

CD to the root of the drive (L:), then change the path as shown. The * is
needed because the folders have text after the ID. Keeps it simple this
way.
You can use long names too. If the filenames contain spaces, use double
quotes around them.

Ihave found the long names didnt work under NT, so had to use short names
There's no need for a temp file. Use the last command without the redirect
as a quoted command in the for statement.
FOR /F "DELIMS=" %%F IN ('findstr /i /m /c:"E000000 "
l:\journa~1\unknow~1\ej*.*') DO (MOVE %%F L:)
All should work fine, however, you could make the script a little shorter as
mentioned.

Does that mean I now only need the last line you mentioned, or simply
replace with your version?
Does the script give any error message or something?

No errors, just doesnt work. The problem is not limited to the script, but
the search function of XP also. If I have a file called EJ123456.001 (which
I know contains the string match) and search for files containing E000001
(incase there are others with this string) then XP will not find any
results. Thats why I think I need to run the searches in compatibility for
NT.
 
S

Simon Hawking

Ok, I think its now working.

But its not giving any visual feedback that files have been moved on XP
systems.

Running on NT systems shows 'x files moved' after each move command.


Why doesnt this work on XP?
 
Ad

Advertisements

X

Xlnt

Simon Hawking said:
Ok, I think its now working.

But its not giving any visual feedback that files have been moved on XP
systems.

Running on NT systems shows 'x files moved' after each move command.


Why doesnt this work on XP?

It only shows the files moved when using wildcards. In other words if you
can't know which files, if any, are moved. When you use the exact path to to
move a file, you know the path of the file already, and it's not displayed.

Xlnt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top