Looping through files, over 100 chars in filenames

Kisu
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?
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.
0
Comments
-
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.0
-
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions