Solved

Scripting

Posted on 2014-01-07
3
171 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now