Re: Using VB to rename and move files ?



Hi, Steven.B

Here are a few things I got from my copy of MSDN. You can use the
online reference at: http://msdn.microsoft.com/library/default.asp


Name Statement


Renames a disk file, directory, or folder.

Syntax

Name oldpathname As newpathname

The Name statement syntax has these parts:

Part Description
oldpathname Required.String expression that specifies the existing file
name and location - may include directory or folder, and drive.
newpathname Required. String expression that specifies the new file
name and location - may include directory or folder, and drive. The
file name specified by newpathname can't already exist.


Remarks

The Name statement renames a file and moves it to a different directory
or folder, if necessary. Name can move a file across drives, but it can
only rename an existing directory or folder when both newpathname and
oldpathname are located on the same drive. Name cannot create a new
file, directory, or folder.

Using Name on an open file produces an error. You must close an open
file before renaming it. Namearguments cannot include
multiple-character (*) and single-character (?) wildcards.


Name Statement Example

This example uses the Name statement to rename a file. For purposes of
this example, assume that the directories or folders that are specified
already exist.

Dim OldName, NewName
OldName = "OLDFILE": NewName = "NEWFILE" ' Define file names.
Name OldName As NewName ' Rename file.

OldName = "C:\MYDIR\OLDFILE": NewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName ' Move and rename file.




SubFolders Property


Description

Returns a Folders collection consisting of all folders contained in a
specified folder, including those with Hidden and System file
attributes set.

Syntax

object.SubFolders

The object is always a Folder object.

Remarks

The following code illustrates the use of the SubFolders property:

Sub ShowFolderList(folderspec)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub







Kill Statement


Deletes files from a disk.

Syntax

Kill pathname

The required pathnameargument is astring expression that specifies one
or more file names to be deleted. The pathname may include the
directory or folder, and the drive.

Remarks

In Microsoft Windows, Kill supports the use of multiple-character (*)
and single-character (?) wildcards to specify multiple files


Kill Statement Example

This example uses the Kill statement to delete a file from a disk.

' Assume TESTFILE is a file containing some data.
Kill "TestFile" ' Delete file.

' Delete all *.TXT files in current directory.
Kill "*.TXT"


I hope this is helpful...if you have anything else, post it here and
I'll see what I can do.

.



Relevant Pages

  • Re: Using VB to rename and move files ?
    ... > name and location - may include directory or folder, ... String expression that specifies the new file ... > This example uses the Name statement to rename a file. ... > Kill Statement Example ...
    (comp.lang.basic.visual.misc)
  • Re: Re-accruing photos in a slideshow
    ... > numerical order and then select this new folder for screen saver but you ... > still will not get the photos to displayed in order. ... > If you want to try it, you can batch rename very quickly using XP. ... > in the order you placed the thumbnails. ...
    (microsoft.public.windowsxp.photos)
  • Re: Creating slideshows in XP
    ... familiar with the Irfanview software, which lets you gather a particular set ... the pictures, and then it closes, i.e. doesn't do a continuous loop. ... I can take that new folder with the renamed files you mentioned and convert ... > If you need to batch rename and number, you can do this easily with XP. ...
    (microsoft.public.windowsxp.photos)
  • Re: autofix failure
    ... One very bad feature about using windows to batch rename your photos: ... I found this out the hard way of course, renamed a whole folder and then ... >>> only when you download the pictures. ...
    (microsoft.public.windowsxp.photos)
  • Re: Missing "Rename" option in My Documents files & folders
    ... General, Shortcut, and Security on a My Documents shortcut. ... Do not share this folder is checked. ... could have something to do with file sharing or ownership. ... Glad you seem to gotten Rename back. ...
    (microsoft.public.windowsxp.help_and_support)