Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Basically, I have a folder with about 20 Word docs in it. I want a BAT that will open the first file in Word, execute a macro that I have written--which includes saving the file and closing Word, then move to the next file.
I've gotten this far:
for %%x in (*.doc) do start c:\progra~1\micros~2\office\winword.exe "%%x" /mmacro1
The problem with this is that it opens all 20 of the documents simultaneously, and won't execute the macro on any of them. Plus, it screws up the normal.dot template because multiple instances of Word are open.Any ideas???

About executing serially add the /Wait switch to the Start command
For %%x in (*.doc) Do Start /Wait C:\Progra~1\Micros~2\Office\WinWord.exe "%%x" /mmacro1
Regarding the execution of the macro that is beyond my know-how.

Perfect!! I knew I was missing something. The /Wait switch was it. The Word macro is my know-how, so I'm good to go. Thanks!
One follow-up question, I have a folder with about 50 different Windows shortcuts. They are all named "Shortcut to <filename>". Is there a way to batch rename them all so that "Shortcut to" is eliminated?

The script below performs what you need
@Echo Off
:: SHREN.BAT Syntax: ShRen FolderNameFor /F "tokens=1,2,*" %%A in ('Dir /B "%*\Shortcut*.*"') Do (
Echo Ren "%*\%%A %%B %%C" "%%C")[the For /F statement is contained in one line ending with "DO (" CR/LF]
To run Type ShRen FolderName where FolderName is the pathname-name of desidered folder; there are no restrictions on the name, i.e. blanks and long file names allowed (e.g. ShRen C:\My Folder\My Documents), but, as you see, omit surrounding quotes anyway.
The script has to be activated removing the Echo in front of Ren: do it only when sure it works as expected.
If anything goes wrong, post again.
Good work

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |