Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Ghostdog, have you tried my script? Does it work for you?
@echo off:: Change "C:\OUTPUT" to output directory with NO "\" at end.set outdir=C:\OUTPUTif not exist "%outdir%" ( echo Output folder not exist. pause >nul exit):: Change "C:\" to input directory with "\" at end.cd C:\set input=:: Check for xmlsif not exist "*.xml" ( echo No .xml files. pause >nul exit):: Set input to last modified .xml in dirfor /f "usebackq delims=" %%I in (`dir /b /a:-d /o:-d "*.xml"`) do ( set input=%%~nI goto out):out:: Grab 'actual' name of pdf from xmlset output=for /f "usebackq tokens=4 delims='" %%I in (`findstr /i "reportSearchPath" "%input%.xml"`) do ( set output=%%I goto copy):copyset output=%output::=-%copy "%input%.pdf" "%outdir%\%output%.pdf"pause
<?xml version="1.0" encoding="utf-8" ?>- <!-- Copyright (C) 2006 Cognos Incorporated. All Rights Reserved. Cognos (R) is a trademark of Cognos Incorporated. -->- <!-- Experimental. Product features described in this file may not be supported in future releases. -->- <outputDescriptor xmlns="http://developer.cognos.com/schema/OutputDescriptor/1.0" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <asOfTime>2007-08-12T13:38:08.093Z</asOfTime> <burstKey /> <contact /> <defaultDescription /> <defaultName>2007-08-12T13:38:09.078Z</defaultName> <fileName>1376_1186940289078.pdf</fileName> <locale>en-us</locale> <owner>rgajendra</owner> <ownerNamespace>COGNOS-DEV Team</ownerNamespace> <parameterValues /> <reportSearchPath>/content/package[@name='Provider']/report[@name='PRV-INT-001:Provider NCPDP Interface Error Report']</reportSearchPath> <reportViewSearchPath>/content/folder[@name='COGNOS-DEV Team']/reportView[@name='Report View of PRV-INT-001:Provider NCPDP Interface Error Report']</reportViewSearchPath> </outputDescriptor>
C:\temp>dir /Btest.pdftest.xmltest1.pdftest1.xmlC:\temp>cd ..C:\>test.bat 1 file(s) copied.Press any key to continue . . .C:\temp>dir /BPRV-INT-001-Provider NCPDP Interface Error Report 2.pdftest.pdftest.xmltest1.pdftest1.xml
Dim objFSO,objFile,objRE,colMatches,oMatchesDim myFiles, srcFolder, dstFolder,dstFile,line,strToFind,strFileNameDim pdfBase,xmlBase,i,strContentsDim pdfStore(),pdfFullStore() 'define some array to store pathsSet objFSO = CreateObject("Scripting.FileSystemObject")srcFolder="c:\temp" 'Server source folder locationdstFolder="c:\temp" 'Destination Folder as desiredi=0 'array counterFor Each myFiles In objFSO.GetFolder(srcFolder).Files If objFSO.GetExtensionName(myFiles) = "pdf" Then pdfBase = objFSO.GetBaseName(myFiles) ReDim Preserve pdfStore(i) ReDim Preserve pdfFullStore(i) pdfStore(i)=pdfBase pdfFullStore(i)=myFiles i=i+1 End If NextFor Each myFiles In objFSO.GetFolder(srcFolder).Files If objFSO.GetExtensionName(myFiles) = "xml" Then xmlBase = objFSO.GetBaseName(myFiles) For i=LBound(pdfStore) To UBound(pdfStore) If pdfStore(i) = xmlBase Then WScript.Echo "found " , xmlBase, pdfStore(i) strToFind = getString(myFiles) dstFile = strToFind&".pdf" objFSO.MoveFile pdfFullStore(i),dstFolder&"\"&dstFile End If Next End If NextFunction getString(theFile) Set objRE = New RegExp objRE.Global = True objRE.IgnoreCase = False objRE.Pattern = "<reportSearchPath>.*/report\[@name='(.*?)'\]</reportSearchPath>" Set objFile=objFSO.OpenTextFile(theFile,1) strContents=objFile.ReadAll Set Matches = objRE.Execute(strContents) For Each match In Matches For Each smatch In match.Submatches result=Replace(smatch,":"," ") Next Next getString = resultEnd Function
C:\vbscript>dir c:\temp /Btest.pdftest.xmltest1.pdftest1.xmlC:\vbscript>cscript /nologo MoveCogNosReports2.vbsfound test testfound test1 test1C:\vbscript>dir c:\temp /BPRV-INT-001 Provider NCPDP Interface Error Report.pdfPRV-INT-002 Provider NCPDP Interface Error Report.pdftest.xmltest1.xml