wasabi3689
asked on
how to run a batch process
I have word convert to PDF .exe program. This program can convert each single Word file to a PDF file. I have a folder with few hundred word files. instead manaully copy/paste each file one by one to generate output file. I want to run a batch process to be able to pick up all the file names from the folder, then run the .exe program and convert each Word file to PDF and output to a location.
How to write this script?
How to write this script?
ASKER
@echo off
pushd Z:\Integration\wordToPDF-ED
for %%a in ("*.doc") do OfficeToPDF.exe "%%~dpnxa" "Z:\Integration\wordToPDF-ED"
popd
I have this error " UNC paths are not supported. Dafaulting to Windows directory"
Z:\Integration\wordToPDF-E
ASKER
Here is he entire error
'\\abc\efg\Integration\wor dToPDF-ED'
CMD.EXE was started with the above path as the current directory
UNC paths are not supported. Defaulting to Windows directory.
My OfficeToPDF.exe is resided in '\\abc\efg\Integration\wor dToPDF-ED'
'\\abc\efg\Integration\wor
CMD.EXE was started with the above path as the current directory
UNC paths are not supported. Defaulting to Windows directory.
My OfficeToPDF.exe is resided in '\\abc\efg\Integration\wor
ASKER
This is Microsoft word to PDF
ASKER
any ideas? help please
Just awoke. 8-)
try this:
try this:
@echo off
cd /d Z:\Integration\wordToPDF-ED
for %%a in ("*.doc") do OfficeToPDF.exe "%%~dpnxa" "Z:\Integration\wordToPDF-ED"
ASKER
Still not working.
If I click on the .bat file as administrator, I have this error
'\\abc\def\Integration\wor dToPDF-ED'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Press any key to continue . . .
If I open a command line to execute the program like below
Z:\Integration\wordToPDF-E D>FileConv ersion.bat
Press any key to continue . . .
Z:\Integration\wordToPDF-E D>
There is no error message but no output file
any ideas?
If I click on the .bat file as administrator, I have this error
'\\abc\def\Integration\wor
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Press any key to continue . . .
If I open a command line to execute the program like below
Z:\Integration\wordToPDF-E
Press any key to continue . . .
Z:\Integration\wordToPDF-E
There is no error message but no output file
any ideas?
- For testing, change to this. It will echo the command but not execute it. Open a command line then run the .bat. Does it look correct?
- Also, you have the input folder the same as the output folder. Is that correct?
- Also, you have the input folder the same as the output folder. Is that correct?
@echo off
cd /d Z:\Integration\wordToPDF-ED
for %%a in ("*.doc") do ECHO OfficeToPDF.exe "%%~dpnxa" "Z:\Integration\wordToPDF-ED"
ASKER
Yes I have the input folder the same as the output folder. But, later I want to change it. So far I want to make work and make it simple first.
ASKER
I ran the .bat program again with ECHO. I have the following
Z:\Integration\wordToPDF-E D>FileConv ersion.bat
OfficeToPDF.exe "Z:\Integration\wordToPDF- ED\36b4c47 7-aacc-4a9 a-b1ee-0c8 cebb73c3
9.doc" "Z:\Integration\wordToPDF- ED"
OfficeToPDF.exe "Z:\Integration\wordToPDF- ED\efbc45c 5-627f-402 4-a5bc-1f8 742b968a
5.doc" "Z:\Integration\wordToPDF- ED"
Press any key to continue . . .
Z:\Integration\wordToPDF-E
OfficeToPDF.exe "Z:\Integration\wordToPDF-
9.doc" "Z:\Integration\wordToPDF-
OfficeToPDF.exe "Z:\Integration\wordToPDF-
5.doc" "Z:\Integration\wordToPDF-
Press any key to continue . . .
If you do each line separately in the command window, does it work?
I don't know what it takes to run OfficeToPDF.exe successfully, e.g. whether the target folder needs to differ or not. You'll need to confirm that.
OfficeToPDF.exe "Z:\Integration\wordToPDF-ED\36b4c477-aacc-4a9a-b1ee-0c8cebb73c39.doc" "Z:\Integration\wordToPDF-ED"
I don't know what it takes to run OfficeToPDF.exe successfully, e.g. whether the target folder needs to differ or not. You'll need to confirm that.
ASKER
The target folder can be different.
if do this line by line, it works
OfficeToPDF.exe "Z:\Integration\wordToPDF- ED\36b4c47 7-aacc-4a9 a-b1ee-0c8 cebb73c39. doc" "Z:\Integration\wordToPDF- ED\36b4c47 7-aacc-4a9 a-b1ee-0c8 cebb73c39. pdf"
if do this line by line, it works
OfficeToPDF.exe "Z:\Integration\wordToPDF-
And if you do it without the target pdf filename it doesn't, right?
OfficeToPDF.exe "Z:\Integration\wordToPDF- ED\36b4c47 7-aacc-4a9 a-b1ee-0c8 cebb73c39. doc" "Z:\Integration\wordToPDF- ED"
Doesn't work, right?
OfficeToPDF.exe "Z:\Integration\wordToPDF-
Doesn't work, right?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
One more thing
If the document has macro, how to also convert the macro in the each file. So far, after the conversion from Word to PDF, part of the contents are lost, like below after open the file
Error! Reference source not found.Error! Reference source not found.
Error! Reference source not found.
DATE : Error! Reference source not found.
VISIT TYPE: Error! Reference source not found.
Error! Reference source not found. Error! Reference source not found.
Error! Reference source not found.
If the document has macro, how to also convert the macro in the each file. So far, after the conversion from Word to PDF, part of the contents are lost, like below after open the file
Error! Reference source not found.Error! Reference source not found.
Error! Reference source not found.
DATE : Error! Reference source not found.
VISIT TYPE: Error! Reference source not found.
Error! Reference source not found. Error! Reference source not found.
Error! Reference source not found.
> ...how to also convert the macro in the each file
Your original question has been answered and solved. Please close the question accordingly.
I am not familiar with OfficeToPDF.
Your original question has been answered and solved. Please close the question accordingly.
I am not familiar with OfficeToPDF.
It's best to do a test against several files first, to make sure it works. It's up to you.
Make file convertpdf.bat with this code:
Open in new window
Open a CMD window
Type: convertpdf.bat