fileRename not working

Started by MW4, December 27, 2018, 11:36:27 AM

Previous topic - Next topic

MW4

I am trying to use a variable pulled from a pdf, and I'm getting a file rename error 123.
I have tried many different ways and I still can't get it to save with the new filename which in my example is B12345.

Any Ideas?

Code (winbatch) Select
RosPdftxt="Y:\Data\Test\PDFS\TodaysRos.txt"

PdfData = FileGet(RosPdftxt)
TotalLines = (ItemCount(pdfdata, @LF) )
 
RosNum = ""

For InvoiceLine = 1 To TotalLines


ThisLine  = ItemExtract(InvoiceLine, pdfdata, @LF)


if strsub(ThisLine, 1, 24) == "OF MULTIPLE NEW VEHICLES"

ThatLine  = ItemExtract(InvoiceLine+1, pdfdata, @LF)
     
RosNum = strsub(ThatLine, 1, 7)
     
endif


next

message(rosnum,rosnum)


;*************************************************************
;*************************************************************


adobe = ObjectCreate("AcroExch.app")      ; create an application object
PDF = ObjectCreate("AcroExch.pdDoc")

PDFFileName = "Y:\Data\Test\PDFS\a.pdf"
t1 = PDF.open(PDFFileName)


StringSave = strcat("Y:\Data\Test\PDFS\" : rosnum : ".pdf")

;message("stringsave",stringsave)
;message("stringsave",%rosnum%)

t2 = PDF.save(1,"Y:\Data\Test\PDFS\aaa.pdf")

PDF.close

adobe.exit; exit the application

adobe = ""      ; close the application object
FirstPDF = ""      ; close the application object

filerename  ("Y:\Data\Test\PDFS\aaa.pdf"  , stringsave)


exit

td

While not related to your problems, why are using both the concatenation operator and the StrCat function on the line:

StringSave = strcat("Y:\Data\Test\PDFS\" : rosnum : ".pdf") ?

You only need to use one or the other but not both.  As is you are just wasting CPU cycles.

Assuming you mean that the 123 system error,  text associated with that error is "The filename, directory name, or volume label syntax is incorrect."  You can find Win32 system error description on our Tech Support site or on Microsoft's site.

The above description is kinda self-explanatory and it isn't possible to tell you what the exact syntax error is because the value of the "RosNum" variable is not discernible without running your script with your data files.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

MW4

That was just the last way I tried to make it work.

StringSave = strcat("Y:\Data\Test\PDFS\", rosnum,".pdf")

StringSave = "Y:\Data\Test\PDFS\" : rosnum : ".pdf"

StringSave = strcat("Y:\Data\Test\PDFS\" : rosnum : ".pdf")

MW4

There was a stray CRLF in there which I used a...

rosnum = StrClean (rosnum, @CRLF, "", @TRUE, 1)  to fix.

Works now

td

The problem was not how you concatenated but what you concatenated. Thanks for letting us know you figured out the what the what was.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade