Move and rename files

dalvarezpenaranda
Member Posts: 4
Hi! I wanna take a 300 files from a folder, I know their extensions but I dont Know what is their name. I would like how to do to rename each one and move into another folder. I found 2 post where explains the code but I can run it into navision. Can I do it with codeunit or with dataport?
Does anyone help?
A lot of thanks!
Does anyone help?
A lot of thanks!
0
Comments
-
global variable:
recFile record : File// This code serves to reset the variable. // For some or other reason, the next times you filter on the same subdir, Navision does NOT update the information recFile.RESET; recFile.SETCURRENTKEY("Path,"Is a file",Name); recFile.SETRANGE("Path,'C:\'); IF recFile.FINDFIRST THEN ; // Now the real code: recFile.RESET; recFile.SETCURRENTKEY("Path,"Is a file",Name); recFile.SETRANGE("Path,'C:\Some subdir'); recFile.SETRANGE("Is a file",TRUE); recFile.SETFILTER(Name,'*.txt'); IF recFile.FINDSET THEN REPEAT MESSAGE('Filename=%1',recFile.Name); UNTIL recFile.NEXT = 0;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
1) use the file-table (virtual table in navision), set the appropriate filters
2) loop through the file-table
3) use the navision rename command
hope this helps
thomas0 -
Boss, The 'File' system table is readonly table. You can not modify it;0
-
The table is indeed read-only. You can use it to search for files, then you need use the rename-command of File (F5=>File=>Functions=>RENAME) and the NOT of the record.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi,
I believe, there are 2 tasks are involved.
1. Renaming the file
2. Moving (same as copy pasting) the file to a new location.
I hv achieved the above tasks with a very simple procedure:
1. used the file record to traverse through the files.
2. created a batch file (.BAT) having dos commands (Move %1 %2)
3. Called the Batch file with navision Shell function.
Filerec.setrange(Path,<ur location>);
IF Filerec.FINDFIRST THEN
Repeat
Shell('<Batch file>',Filerec.Path + '\'+Filerec.name + ' ' + <New file name with path of new location>);
Until Next = 0;
Message(Processing Complete');
Thanx
Snehanshu0 -
Better use http://www.mibuso.com/forum/viewtopic.php?t=12417 in stead of the SHELL-command.
With this you can use "cmd.exe /C move ..." and you can avoid the dos-box.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
i know this is old but i stubled over it thanks to google. So.. in case someone else has the same fate:
you could just loop through the files with the help of the virtual file table as kriki described and then use the "File.rename"-command somehow like this:vars: ShortFileName[text] GLSetup[rec of general ledger setup] ArchiveFile(_Filename : Text[1024]) ShortFileName := _Filename; WHILE STRPOS(ShortFileName, '\') <> 0 DO ShortFileName := COPYSTR(ShortFileName, 1 + STRPOS(ShortFileName, '\')); FILE.RENAME(_Filename, GLSetup."Archive Folder" + ShortFileName);
p.s. i recomend to always use the absolute path 'cause nav tends to mess with the workingfolder.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