Peter Wilcox
asked on
Dos FOR loop question
Here is my batch file.
For /f %%a IN (‘R:\ /b *.mdb’) do call "C:\Program Files\Microsoft Office\Office14\msaccess.e xe" %%a /compact
I am trying to run through the R drive and grab all the .mdb's and do compact from msaccess but when I run this through command prompt I get this error:
%%a was unexpected at this time
Any suggestions on how to get this For loop command to work properly.
For /f %%a IN (‘R:\ /b *.mdb’) do call "C:\Program Files\Microsoft Office\Office14\msaccess.e
I am trying to run through the R drive and grab all the .mdb's and do compact from msaccess but when I run this through command prompt I get this error:
%%a was unexpected at this time
Any suggestions on how to get this For loop command to work properly.
you cut and paste, didn't you?
:-)
You have:
For /f %%a IN (‘R:\ /b *.mdb’) do call "C:\Program Files\Microsoft Office\Office14\msaccess.e xe" %%a /compact
try
For /f %%a IN ('R:\ /b *.mdb') do call "C:\Program Files\Microsoft Office\Office14\msaccess.e xe" %%a /compact
(Note the TYPE of quote surrounding R:\ /b *.mdb)
:-)
You have:
For /f %%a IN (‘R:\ /b *.mdb’) do call "C:\Program Files\Microsoft Office\Office14\msaccess.e
try
For /f %%a IN ('R:\ /b *.mdb') do call "C:\Program Files\Microsoft Office\Office14\msaccess.e
(Note the TYPE of quote surrounding R:\ /b *.mdb)
ASKER
I did but I still get the same message...
3-4-2011-4-40-03-PM.jpg
3-4-2011-4-40-03-PM.jpg
I think he means:
IN ('dir/s/b R:\*.mdb')
IN ('dir/s/b R:\*.mdb')
... and if any of your .mdb files have spaces in the name, put quotes here: "%%a" /compact
Oh and the obvious... if you are typing that at the command line use %a instead of %%a (which is for batch files).
Steve
Steve
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry Steve, didn't refresh the page :(
ASKER
Is there a way to exclude specific MDB's?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://jamesewelch.wordpress.com/2008/05/01/how-to-write-a-dos-batch-file-to-loop-through-files/
http://www.computerhope.com/forhlp.htm
http://www.robvanderwoude.com/for.php