Solved

Scripting

Posted on 2014-01-07
3
181 Views
Last Modified: 2014-01-07
Hi Guys

Does anyone have an idea of how to work out if a folder is at the "end" of a folder structure?

Ie. it doesn't have any more folders in it?

Thanks
rory
0
Comment
Question by:Whitservices
3 Comments
 
LVL 16

Expert Comment

by:choward16980
ID: 39762586
Dir *.
returns directory list.

standard last line is X Dir(s)  XXXXXXXXXX bytes free.

If you ran dir *. and checked the last line, 1st token against the value equal to 2, it should be at the end of the structure.  Assuming there are no hidden or system directories.
0
 
LVL 26

Accepted Solution

by:
pony10us earned 500 total points
ID: 39762947
The following should work as long as you don't have any files WITHOUT extensions.

(get-childitem -filter "*.").count
if ($_count -ne $null) {
	Echo " Not last folder"
}
Else
{
	Echo "Last folder"
}

Open in new window

0
 

Author Closing Comment

by:Whitservices
ID: 39763666
Fantastic, thanks very much.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A safe way to clean winsxs folder from your windows server 2008 R2 editions
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question