Output directly to the desstination folder so that output is not lost after partial completion.

Add the ability to skip processing of some of the Folders
Added logic to save the name of the folder if it contains reserved characters (space, dash, slash and backslash)
This commit is contained in:
Rich 2018-12-03 19:25:55 +00:00
parent 62a4d3de06
commit 429064af6b

View File

@ -37,9 +37,10 @@ ECHO AAA >%TEMP%\VEPROMS\NewFile.txt
for %%a in (%TEMP%\VEPROMS\NewFile.txt) do Set fdt=%%~ta for %%a in (%TEMP%\VEPROMS\NewFile.txt) do Set fdt=%%~ta
for /F "tokens=1,2,3,4,5,6 delims=/: " %%i in (''echo %fdt%'') do call:sc_FixTime %%k %%i %%j %%n %%l %%m for /F "tokens=1,2,3,4,5,6 delims=/: " %%i in (''echo %fdt%'') do call:sc_FixTime %%k %%i %%j %%n %%l %%m
set fdt=%fdt::=%_%GroupComment% set fdt=%fdt::=%_%GroupComment%
set ServerName=' + @@Servername + ' set ServerName=' + @@Servername + '
md %TEMP%\VEPROMS\%fdt% md %TEMP%\VEPROMS\%fdt%
echo %date% %time% Start ' + @@Servername + ' ' + DB_NAME() + '%GroupComment% >>%TEMP%\VEPROMS\%fdt%\Times.txt md C:\PDFs\%fdt%
echo %date% %time% Start ' + @@Servername + ' ' + DB_NAME() + '%GroupComment% >>C:\pdfs\%fdt%\Times.txt
del %TEMP%\VEPROMS\NewFile.txt del %TEMP%\VEPROMS\NewFile.txt
Rem Cleanup output folder before processing Rem Cleanup output folder before processing
del %temp%\VEPROMS\*.txt del %temp%\VEPROMS\*.txt
@ -50,13 +51,16 @@ if ERRORLEVEL 1 goto :oops
Rem Update Formats Rem Update Formats
call :sc_setformats unnecessary unnecessary ' + DB_NAME() + ' unnecessary %PROMSEXE% call :sc_setformats unnecessary unnecessary ' + DB_NAME() + ' unnecessary %PROMSEXE%
Rem Perform PROMS printing for each Folder ---------------------------------------- Rem Perform PROMS printing for each Folder ----------------------------------------
GoTo :SkipStart
Rem Skip some DocVersions (Working Drafts)
:SkipStart
' '
declare @CommandLine nvarchar(255) declare @CommandLine nvarchar(255)
declare Commands cursor for declare Commands cursor for
select 'Call :sc_PrintPDF %TEMP%\VEPROMS ' + select 'Call :sc_PrintPDF %TEMP%\VEPROMS ' +
cast(VersionID as varchar(5))+ ' ' + db_name() + ' ' + cast(VersionID as varchar(5))+ ' ' + db_name() + ' ' +
Replace(Replace(ff.name,' ','_'),'-','_') + ' %PROMSEXE%' Replace(Replace(Replace(Replace(ff.name,'/','_'),'\','_'),' ','_'),'-','_') + ' %PROMSEXE%'
from docversions dv from docversions dv
join folders ff on dv.folderID = ff.FolderID join folders ff on dv.folderID = ff.FolderID
order by versionID order by versionID
@ -69,10 +73,14 @@ BEGIN
END END
CLOSE Commands CLOSE Commands
DEALLOCATE Commands DEALLOCATE Commands
PRINT 'Call :sc_MoveErrorLog ' + db_name() +' PRINT 'GoTo :SkipEnd
Rem Skip Some DocVersions (Working Drafts)
echo %date% %time% Done >>%TEMP%\VEPROMS\%fdt%\Times.txt :SkipEnd
Move %TEMP%\VEPROMS\%fdt% C:\PDFs\%fdt% Call :sc_MoveErrorLog ' + db_name() +'
Rem Record direcctly to C:\PDFs\%fdt%
echo %date% %time% Done >>C:\PDFS\%fdt%\Times.txt
Move %TEMP%\VEPROMS\%fdt%\*.* C:\PDFs\%fdt%
rd %TEMP%\VEPROMS\%fdt%
set GroupComment= set GroupComment=
set fdt= set fdt=
@ -86,23 +94,23 @@ timeout /T 10
goto:eof goto:eof
:sc_PrintPDF :sc_PrintPDF
echo %date% %time% Start %2 (%4) >>%TEMP%\VEPROMS\%fdt%\Times.txt echo %date% %time% Start %2 (%4) >>C:\PDFS\%fdt%\Times.txt
echo Creating PDFs for DocVersion %2 (%4) in %3 echo Creating PDFs for DocVersion %2 (%4) in %3
rem del %userprofile%\Documents\VEPROMS\%3*.txt rem del %userprofile%\Documents\VEPROMS\%3*.txt
"C:\PROMS\%5\VEPROMS.exe" /P=%2 /DB=%ServerName%:%3 /NT /NC "C:\PROMS\%5\VEPROMS.exe" /P=%2 /DB=%ServerName%:%3 /NT /NC
rem ----------------------------------------------- rem -----------------------------------------------
rem Add /NW to exclude Word Output to the Meta File rem Add /NW to exclude Word Output to the Meta File
rem ----------------------------------------------- rem -----------------------------------------------
echo %date% %time% Done %2 (%4) >>%TEMP%\VEPROMS\%fdt%\Times.txt echo %date% %time% Done %2 (%4) >>C:\PDFS\%fdt%\Times.txt
call :sc_AddText %3 %2 %4 %5 call :sc_AddText %3 %2 %4 %5
C: C:
cd %1 cd %1
if not exist DebugP*.txt goto:sc_PrintPDFNoFiles if not exist DebugP*.txt goto:sc_PrintPDFNoFiles
set fdt1=%fdt%\%3\%2_%4 set fdt1=%fdt%\%3\%2_%4
md %fdt1% md c:\PDFs\%fdt1%
del DOC_*.pdf > nul del DOC_*.pdf > nul
move *.pdf %fdt1% > nul move *.pdf c:\PDFs\%fdt1% > nul
move *.txt %fdt1% > nul move *.txt c:\PDFs\%fdt1% > nul
for /F %%c in (''cd'') do echo Files Moved to %%c\%fdt1% for /F %%c in (''cd'') do echo Files Moved to %%c\%fdt1%
set fdt1= set fdt1=
goto:eof goto:eof
@ -131,7 +139,7 @@ echo %2/%3/%1 %5:%6 %4 %fdt%
goto:eof goto:eof
:sc_MoveErrorLog :sc_MoveErrorLog
move %userprofile%\Documents\VEPROMS\%1*.txt %fdt%\%1 > nul move %userprofile%\Documents\VEPROMS\%1*.txt C:\PDFS\%fdt%\%1 > nul
goto:eof goto:eof
:sc_AddText :sc_AddText