I need help
If I coded
GetFileList>E:\test\*.txt,files
Separate>Files,;,file_names
bla bla
I will the whole path included the file name
example: file_names = E:\test\testfile1.txt
which is i dont need the whole path
I need to get the file only >> testfile1.txt
thanks
How to get the file name ?
Moderators: JRL, Dorian (MJT support)
There are many different ways to strip off the path from the file name. Here is one example.
This example works with the typical path and file...c:\folder\folder\MyFile.txt
Code: Select all
let>FileAndPath=C:\Folder\Folder\MyFile.txt
sep>%FileAndPath%,\,seg
let>max=seg_count
pos>.,seg_%max%,1,vDot
if>vDot>0
sep>seg_%max%,.,fseg
let>FileExt=fseg_2
let>TheFile=%fseg_1%.%FileExt%
else
let>TheFile=%fseg_1%
endif
mdl>the file is %TheFile%
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Or another approach that doesn't care about the filename format:
Code: Select all
Let>mydir=c:\temp\
GetFileList>%mydir%*.*,files
StringReplace>files,%mydir%,,files2
Separate>files2,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
MessageModal>file_names_%k%
Until>k,file_names_count