PC Review


Reply
Thread Tools Rate Thread

Batch subfolder renaming

 
 
Bruce
Guest
Posts: n/a
 
      11th Mar 2005
Hi,

Part of my database processing is to copy a template folder structure
from the Masters into the Project folder and prefix all these copied
folders with the Project number.

I have executed the first part ok with the CopyFolder function.

The second part is a bit harder. I need to count all the subfolders,
then loop through them one at a time prefixing them with the Project
Number to subfolders two levels deep (I didn't set up the system, I
just gotta work with it).

I've tried using the Folder object but I don't know how to specify a
directory.
I've tried the looping method using the Dir function as provided by
Microsoft help, but I can't specify a deep enough structure.

The logic language of what I want to do is:

For i = 1 to NewFolder(Level 2).Subfolders.Count
With NewFolder(Level 2)
.Subfolder(i).Name = strProjectNumber & " " & _
.Subfolder(i).Name
End With
Next i

Any ideas?

Cheers,

Bruce P Walker
 
Reply With Quote
 
 
 
 
Bruce
Guest
Posts: n/a
 
      23rd Mar 2005
(E-Mail Removed) (Bruce) wrote in message news:<(E-Mail Removed)>...

Never mind, I solved it with the following code:

Dim strDirectory, strProjectRef As String
Dim strFolderName, strDestination As String
Dim fso As Object
Dim fdrNewFolder As Folder
Set fso = CreateObject("Scripting.FileSystemObject")

'Copy Project Folder Setup across and rename
fso.copyfolder strFolderSetup, strDirectory, False

'Set directory to "\Drawings"
strDirectory = strDirectory & strSub1

'Rename appropriate subfolders with Project Number
For i = 1 To 2
strFolderName = Dir(strDirectory, vbDirectory) ' Retrieve the
first entry.
Do While strFolderName <> ""
' Ignore the current directory and the encompassing directory.
If strFolderName <> "." And strFolderName <> ".." Then
' Use bitwise comparison to make sure strFolderName is a
directory.
If (GetAttr(strDirectory & strFolderName) And vbDirectory)
= vbDirectory Then
Name strDirectory & strFolderName As strDirectory &
strProjectNo & strFolderName
End If
End If
strFolderName = Dir ' Get next entry.
Loop
strDirectory = strDestination & strProjectRef & "\"
Next i
 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      23rd Mar 2005
Just a comment. I'll bet you think that

Dim strDirectory, strProjectRef As String
Dim strFolderName, strDestination As String

declares 4 string variables. It doesn't: strDirectory and strFolderName are
both being declared as variants.

To get them all as strings, you need:

Dim strDirectory As String, strProjectRef As String
Dim strFolderName As String, strDestination As String


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Bruce" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (E-Mail Removed) (Bruce) wrote in message
> news:<(E-Mail Removed)>...
>
> Never mind, I solved it with the following code:
>
> Dim strDirectory, strProjectRef As String
> Dim strFolderName, strDestination As String
> Dim fso As Object
> Dim fdrNewFolder As Folder
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> 'Copy Project Folder Setup across and rename
> fso.copyfolder strFolderSetup, strDirectory, False
>
> 'Set directory to "\Drawings"
> strDirectory = strDirectory & strSub1
>
> 'Rename appropriate subfolders with Project Number
> For i = 1 To 2
> strFolderName = Dir(strDirectory, vbDirectory) ' Retrieve the
> first entry.
> Do While strFolderName <> ""
> ' Ignore the current directory and the encompassing directory.
> If strFolderName <> "." And strFolderName <> ".." Then
> ' Use bitwise comparison to make sure strFolderName is a
> directory.
> If (GetAttr(strDirectory & strFolderName) And vbDirectory)
> = vbDirectory Then
> Name strDirectory & strFolderName As strDirectory &
> strProjectNo & strFolderName
> End If
> End If
> strFolderName = Dir ' Get next entry.
> Loop
> strDirectory = strDestination & strProjectRef & "\"
> Next i



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut or batch to go to local subfolder Frank Spade Windows XP General 3 5th Aug 2010 11:37 AM
BATCH PHOTO RENAMING Jason Bahrs Microsoft Word Document Management 1 1st Apr 2008 06:40 AM
Batch renaming of worksheets =?Utf-8?B?THVtZW4gUw==?= Microsoft Excel Misc 1 17th Aug 2006 08:35 PM
Renaming a batch of files Francis Hookam Windows XP General 2 27th Oct 2004 12:24 PM
Re: renaming subfolder contacts? Russ Valentine [MVP-Outlook] Microsoft Outlook Contacts 1 10th Sep 2003 08:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:24 PM.