I have already posted how to find the content of folder with vb
if you you want to separate file name from file path & file name then use below formula
suppose your cell A1 contain C:\Users\MAHESH\Downloads\Data sample.xls
=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2,"\","*",LEN(A2)-LEN(SUBSTITUTE(A2,"\","")))))
results will be Data sample.xls
You can try below DOS command to directory of the folder & sub folder
c:\User> Dir/s/b > F:\file.txt
this will save all the list of file (Directory) in F drive in file.txt you can use file.xls to save output as excel file
if you you want to separate file name from file path & file name then use below formula
suppose your cell A1 contain C:\Users\MAHESH\Downloads\Data sample.xls
=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2,"\","*",LEN(A2)-LEN(SUBSTITUTE(A2,"\","")))))
results will be Data sample.xls
- Find total len of cell LEN(A1) =41
- find Len of cell without "\" using SUBSTITUTE LEN(SUBSTITUTE(A1,"\","") =37
- (1-2) will give u count of number of backslash "\" i.e (41-37=4)
- we got last position of bracket is 4, but don’t know the string position in cell
- Find function always find the first instance
- Use the SUBSTITUTE function to change the last backslash
- FIND("*",SUBSTITUTE(A1,"\","*",4) will give you position of last backslash i.e 26
- we are replacing last back slash as * to get the position of last backslash
- we have taken 4 (number of backslash) as instance_num in substitute formula
- Use Right function which will give you file name
You can try below DOS command to directory of the folder & sub folder
c:\User> Dir/s/b > F:\file.txt
this will save all the list of file (Directory) in F drive in file.txt you can use file.xls to save output as excel file
No comments:
Post a Comment