[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VBScript that will run through several folder trees and run this script on each folder in the tree

Posted on 2006-06-08
1
Medium Priority
?
709 Views
Last Modified: 2012-06-27
I am having a difficult time creating a script that will run through various folder trees and run the following script on every document with in the folder.

'Set Type of Files To Act Upon
DocumentType="Microsoft PowerPoint Presentation"

'Generate Objects for Filesystem, Folder, and Files within the current folder
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
Set FileSysFolder = FileSysObj.GetFolder(FileSysObj.GetAbsolutePathName("folder path"))
Set FileSysFiles = FileSysFolder.Files

Set PowerPoint = CreateObject("PowerPoint.Application")
PowerPoint.Visible = False

'Loop through each File In the Folder
For Each ObjFile in FileSysFiles
  If (objFile.Type = DocumentType) Then
     Pres_Name = FileSysFolder & "\" & objFile.Name
     PowerPoint.Presentations.Open(Pres_Name)
     PowerPoint.Presentations(Pres_Name).BuiltInDocumentProperties("Title").Value = PowerPoint.Presentations(Pres_Name).Name
     PowerPoint.Presentations(Pres_Name).Save()
     PowerPoint.Presentations(Pres_Name).Close()
  End If
Next

PowerPoint.Quit

These folders are for archived documents, so they go from year, month, and day.  I have no idea how to create a script that will perform the script on every folder.
0
Comment
Question by:jlakor
1 Comment
 
LVL 44

Accepted Solution

by:
bruintje earned 1000 total points
ID: 16860593
Hi jlakor,
----------

you'll find a recursive showfolders function here for that purpose
http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1020.mspx


ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Wscript.Echo Subfolder.Path
        Set objFolder = objFSO.GetFolder(Subfolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles
            Wscript.Echo objFile.Name
        Next
        Wscript.Echo
        ShowSubFolders Subfolder
    Next
End Sub

it loops through all files in the startfolder then goes below and does the same for all subfolders
----------
bruintje
share what you know, learn what you don't
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

829 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