If period "." located in string, return "File", else return "DIR"

Jason Campbell

Board Regular
Joined
Mar 22, 2016
Messages
77
Dear all,

I have been tasked with reviewing network directories and files to etsablish when the directories and files were last accessed. This being in an effort to remove redundant directories and data that is no longer being used.

I have used the command line to extract the required data using the DIR /s /ta command to list the root directory & subdirectories, showing the date and time those directories and files were last accessed.

I've then taken the data and pasted it into a spreadsheet. The returned data is all placed within one cell for each date, time, DIR marker and DIR name or file name, as per below:


[TABLE="width: 624"]
<tbody>[TR]
[TD]25/04/2016 19:42 <DIR> archive
[/TD]
[/TR]
[TR]
[TD]18/09/2015 22:59 6,915,884 ABC_BB_2015-16_v7_singles.pdf

I have managed to extract the date, time, and directory name into thier own cells or each record. However, I have noted that I need to distinguish between a directory (<DIR>) and a direcotry file, which has a .??? extension.
[TABLE="width: 656"]
<tbody>[TR]
[TD]Date Last Accessed
[/TD]
[TD]Time
[/TD]
[TD] Type
[/TD]
[TD]Directory Name
[/TD]
[/TR]
[TR]
[TD]15/12/2017
[/TD]
[TD]10:54
[/TD]
[TD] DIR
[/TD]
[TD]2014 Business Plan and Review Matrix
[/TD]
[/TR]
[TR]
[TD]25/04/2016
[/TD]
[TD]19:10
[/TD]
[TD] DIR
[/TD]
[TD]2015 Business Plan and Review Matrix
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



  1. The formula that I have used in the 'Type' field is as follows:
    =TRIM(IF(MID(B22,SEARCH("<",B22)+1,3)="DIR","DIR",IF(RIGHT(B22,4)=".","File")))

    This works fine at identifying the <DIR> part of the text string, however returns the #VALUE ! error when presented with a cell string as follow:
    18/09/2015 22:59 6,915,884 ABC_BB_2015-16_v7_singles.pdf

    Can anyone give me some pointers on how to get excel to recognise the "." and return "File" in that instance?

    Many thanks in advance.

    Jason
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top