[AccessD] is it possible to rename many folders via access?

Kostas Konstantinidis kost36 at otenet.gr
Tue Jan 17 13:57:20 CST 2006


Jurgen and Gustav,
many thank's for your help.

/kostas

----- Original Message ----- 
From: "Gustav Brock" <Gustav at cactus.dk>
To: <accessd at databaseadvisors.com>
Sent: Sunday, January 15, 2006 8:52 PM
Subject: Re: [AccessD] is it possible to rename many folders via access?


> Hi Jürgen and Kostas
>
> Right, you have to be careful - you could destroy a complete folder 
> structure with this code if you get something wrong!
>
> Now I recall I have a helper function to get around some of the 
> limitations of Dir.
>
> <code>
>
> Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias 
> "PathIsDirectoryA" ( _
>  ByVal pszPath As String) _
>  As Long
>
> Public Function IsDir( _
>  ByVal strPath As String) _
>  As Boolean
>
> ' Returns True if strPath exists.
>
>  Dim stzPath As String
>
>  stzPath = strPath & vbNullChar
>
>  IsDir = CBool(PathIsDirectory(stzPath))
>
> End Function
>
> </code>
>
> Use this and every other error check you can think of, like:
>
>  If IsDate("1/1/" & Val(Mid(strNewName, 2))) Then
>    ...
>  End if
>
> /gustav
>
>
>>>> jwelz at hotmail.com 15-01-2006 19:28:23 >>>
> Gustav is of course correct, you need to pass the  vbDirectory parameter 
> to
> Dir in order to include folder names in the search and I had neglected to
> include this detail.
>
> Including this parameter allows Dir to return folders, but it does not
> restrict return values to folders.  It still returns files.
>
> Gustav's file spec, '*.', parameter ordinarily ensures that only files 
> will
> be returned.  However, folders may be given an extension or include a '.'
> and these will be excluded by that spec.  Also, this would return file 
> names
> that lack an extension.  In Kostas' case this is probably irrelevant since
> probably no folder names contain a '.' and there are not likely to be any
> files without an extension that would be returned by Dir.
>
> You would want to be sure that your Dir function returns test with IsDate 
> on
> a portion of the folder name beyond the 5th character that match a year
> between 1900 and 2006 (or IsNumeric).  After all, you wouldn't want Dir to
> find a renamed folder and perhaps rename it again ad infinitum, perhaps
> scrambling the folder names beyond all recognition.  You need to be sure
> your string manipulation recognizes a renamed folder.  I still use instr()
> and would test for the location of the first parenthesis.
>
> Ciao
> Jürgen Welz
> Edmonton, Alberta
> jwelz at hotmail.com
>
>
>
>
>
>>From: "Gustav Brock" <Gustav at cactus.dk>
>
>>Hi Kostas
>>
>>Well, Dir will list your folders:
>>
>>   ' Find first folder.
>>   strFolder = Dir(strParent & "\*.", vbDirectory)
>>   While Len(strFolder) > 0
>>     ' Pick movie.
>>     strName = Split(strFolder, "-")(0)
>>     lngLen = Len(strName)
>>     ' Rearrange movie and concatenate with composer.
>>     strNewName = Right(strName, 6) & " " & Left(strName, lngLen - 7) & 
>> "-"
>>& Split(strFolder, "-")(1)
>>     ' Build old and new path.
>>     strPath = strParent & "\" & strFolder
>>     strNewPath = strParent & "\" & strNewName
>>     ' Rename folder.
>>     Name strPath As strNewPath
>>     ' Find next folder.
>>     strFolder = Dir
>>   Wend
>>
>>/gustav
>>
>> >>> kost36 at otenet.gr 16-01-2006 17:46:16 >>>
>>Jurgen,
>>KING KONG was just an example.
>>every folder has its unic name
>>My example was refferenced to that, trying to explain the format of the
>>folder names e.g.
>>
>>Movie Title (Year) - Composer
>>
>>thank's for your response
>>/kostas
>>
>>----- Original Message -----
>>From: "Jurgen Welz" <jwelz at hotmail.com>
>>To: <accessd at databaseadvisors.com>
>>Sent: Sunday, January 15, 2006 6:37 PM
>>Subject: Re: [AccessD] is it possible to rename many folders via access?
>>
>>
>> > Kostas:
>> >
>> > You can use the Dir function to return file/folder names that match the
>> > spec, check the return value as to whether it is a directory with
>>GetAttr
>> > (If (GetAttr(strDirReturn) And vbDirectory) = vbDirectory Then) and 
>> > then
>> > use
>> > the Name "C:\FilePath" As "C:\NewFilePath" syntax to rename folders.
>> >
>> > Obviously all your folders can't have the same name and be in the same
>> > location.  EIther they are elsewhere in the directory structure or on
>> > various drives and/or machines.  You'll either need to to a recursive
>> > search
>> > with the Dir function to return the original folder names, unless the
>> > folders have some kind of suffix like:  KING KONG (1933) - Max Steiner
>>A.
>> >
>> > Do all the folders have exactly the same name, or is that just the 
>> > start
>> > of
>> > the name and they have various suffixes and share the same root?
>> >
>> >
>> >
>> > Ciao
>> > Jürgen Welz
>> > Edmonton, Alberta
>> > jwelz at hotmail.com
>> >
>> >
>> >
>> >
>> >
>> >>From: "Kostas Konstantinidis" <kost36 at otenet.gr>
>> >>
>> >>I have about 7.000 folders saved as .
>> >>KING KONG (1933) - Max Steiner
>> >>what I want to do is to rename all the folders as
>> >>(1933) KING KONG - Max Steiner
>> >>
>> >>is that possible?
>> >>thank's a lot
>> >>/kostas
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
>
> 





More information about the AccessD mailing list