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:


25/04/2016 19:42 <DIR> archive
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.
Date Last Accessed
Time
Type
Directory Name
15/12/2017
10:54
DIR
2014 Business Plan and Review Matrix
25/04/2016
19:10
DIR
2015 Business Plan and Review Matrix

<tbody>
</tbody>

<tbody>
</tbody>



  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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,216,033
Messages
6,128,427
Members
449,450
Latest member
gunars

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