Looping through files, over 100 chars in filenames

KisuKisu Member Posts: 381
I stumbled upon problem with filename length.

I have set of xml files and some pdf that belongs to those xml files.
I want to loop through the pdf files and strip the filenames shorter to match the xml filenames

xml files are named like this:
1234567a-1234-abcd-abcd-1234567890a_invoice_123456789.xml

and pdf names like this:
1234567a-1234-abcd-abcd-1234567890a_image_123456789_portname_invoicename_exportdate_importdate_somethingnotsousualtext.pdf

the pdf should be renamed like:
1234567a-1234-abcd-abcd-1234567890a_image.pdf

I'm using Record File table for looping through the files like so:


cfile.RESET;
cfile.SETRANGE(cfile.Path, Laskukansio);
cfile.SETRANGE("Is a file", TRUE);
cfile.SETFILTER(cfile.Name, '*.pdf');

IF cfile.FINDFIRST THEN BEGIN
REPEAT...

This loop skips that long pdf file as it's over 100 chars, but if I leave the pdf filter out, part of the name shows upon cfile.name
1234567a-1234-abcd-abcd-1234567890a_image_123456789_portname_invoicename_exportdate_importdate_som

So is there anyway I could rename these long file names within Navision?
K.S.

Comments

  • sourav_aitsourav_ait Member Posts: 15
    Is there any nomenclature you follow for the file name?The only way to rename the name as you want is by wrapping the name.
  • vaprogvaprog Member Posts: 1,140
    Hi,

    if you happen to know the filename, FILE.RENAME should work. I assume, that here, the 260 character WINAPI restriction for the full path applies.

    If you need to find the file first, I suggest you use DotNet interop (or Automation, if you're on classic) for that purpose. You can use it for rename also.
Sign In or Register to comment.