PC Review


Reply
Thread Tools Rate Thread

Copy List of Files using Excel

 
 
KateB
Guest
Posts: n/a
 
      11th Aug 2009
Hi,

I have a many tif files (1000's) for which I have a master list in
excel. I'd like to be able to filter the list & copy the filtered
list of tifs to a new location (i.e. c:\NewFiles). The tif files are
organised in a couple of subdirectories, which I suspect makes this
harder.

I've had a bit of a dig through the group, but haven't been able to
turn anything up. Any suggestions? Using Excel 03.

Thanks,
Kate
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      11th Aug 2009
Does the master list contain the paths (including subfolder) ?
You should be able to loop through the filtered list and just copy each of
the files.
The FileSystem object has methods for moving/copying files (add a reference
to "Microsoft Scripting Runtime")

Tim

"KateB" <(E-Mail Removed)> wrote in message
news:b80661e6-14fd-40f8-a2c0-(E-Mail Removed)...
> Hi,
>
> I have a many tif files (1000's) for which I have a master list in
> excel. I'd like to be able to filter the list & copy the filtered
> list of tifs to a new location (i.e. c:\NewFiles). The tif files are
> organised in a couple of subdirectories, which I suspect makes this
> harder.
>
> I've had a bit of a dig through the group, but haven't been able to
> turn anything up. Any suggestions? Using Excel 03.
>
> Thanks,
> Kate



 
Reply With Quote
 
KateB
Guest
Posts: n/a
 
      11th Aug 2009
Yes, the full path for each file is in the cell. Don't suppose you
could give me a demo with the FileSystem object? I'm a bit of a self-
taught hack in VBA (mostly through editing the macro recorder, but
unfortunately that doesn't work for things outside of excel like this)

Thanks!
Kate

On Aug 11, 12:29*pm, "Tim Williams" <timjwilli...@comcast.net> wrote:
> Does the master list contain the paths (including subfolder) ?
> You should be able to loop through the filtered list and just copy each of
> the files.
> The FileSystem object has methods for moving/copying files (add a reference
> to "Microsoft Scripting Runtime")
>
> Tim
>
> "KateB" <kate.e.be...@gmail.com> wrote in message
>
> news:b80661e6-14fd-40f8-a2c0-(E-Mail Removed)...
>
> > Hi,

>
> > I have a many tif files (1000's) for which I have a master list in
> > excel. *I'd like to be able to filter the list & copy the filtered
> > list of tifs to a new location (i.e. c:\NewFiles). *The tif files are
> > organised in a couple of subdirectories, which I suspect makes this
> > harder.

>
> > I've had a bit of a dig through the group, but haven't been able to
> > turn anything up. *Any suggestions? *Using Excel 03.

>
> > Thanks,
> > Kate


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      11th Aug 2009
Look at the "Name" function, from help

OldName = "C:\MYDIR\OLDFILE"
NewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName

If not sure how to incorporate that into a loop post examples of what you
have in cells (and cell ref's) and where you want your files to go

Regards,
Peter T



"KateB" <(E-Mail Removed)> wrote in message
news:fa2b59ca-b7f6-4fc2-b74f-(E-Mail Removed)...
Yes, the full path for each file is in the cell. Don't suppose you
could give me a demo with the FileSystem object? I'm a bit of a self-
taught hack in VBA (mostly through editing the macro recorder, but
unfortunately that doesn't work for things outside of excel like this)

Thanks!
Kate

On Aug 11, 12:29 pm, "Tim Williams" <timjwilli...@comcast.net> wrote:
> Does the master list contain the paths (including subfolder) ?
> You should be able to loop through the filtered list and just copy each of
> the files.
> The FileSystem object has methods for moving/copying files (add a
> reference
> to "Microsoft Scripting Runtime")
>
> Tim
>
> "KateB" <kate.e.be...@gmail.com> wrote in message
>
> news:b80661e6-14fd-40f8-a2c0-(E-Mail Removed)...
>
> > Hi,

>
> > I have a many tif files (1000's) for which I have a master list in
> > excel. I'd like to be able to filter the list & copy the filtered
> > list of tifs to a new location (i.e. c:\NewFiles). The tif files are
> > organised in a couple of subdirectories, which I suspect makes this
> > harder.

>
> > I've had a bit of a dig through the group, but haven't been able to
> > turn anything up. Any suggestions? Using Excel 03.

>
> > Thanks,
> > Kate



 
Reply With Quote
 
KateB
Guest
Posts: n/a
 
      11th Aug 2009
I tried this as a dodgy first-pass, but it's hanging on the "Name
oldName As NewName" part - it says "Run time error '53' - File not
found". The file is definately there, if I click the hyperlink in
excel, it opens up. Any ideas? The list of files starts in cell A1.

Thanks,
Kate


Sub copyFiles()
strDirectory = "c:\OldSite"
strDestFolder = "c:\test"

For i = 1 To 28

oldName = Cells(i, 1).Value
truncName = Right(oldName, Len(oldName) - 3)
NewName = strDestFolder & "\" & truncName
Name oldName As NewName

Next i


End Sub


On Aug 11, 8:54*pm, "Peter T" <peter_t@discussions> wrote:
> Look at the "Name" function, from help
>
> OldName = "C:\MYDIR\OLDFILE"
> NewName = "C:\YOURDIR\NEWFILE"
> Name OldName As NewName
>
> If not sure how to incorporate that into a loop post examples of what you
> have in cells (and cell ref's) and where you want your files to go
>
> Regards,
> Peter T
>
> "KateB" <kate.e.be...@gmail.com> wrote in message
>
> news:fa2b59ca-b7f6-4fc2-b74f-(E-Mail Removed)...
> Yes, the full path for each file is in the cell. *Don't suppose you
> could give me a demo with the FileSystem object? *I'm a bit of a self-
> taught hack in VBA (mostly through editing the macro recorder, but
> unfortunately that doesn't work for things outside of excel like this)
>
> Thanks!
> Kate
>
> On Aug 11, 12:29 pm, "Tim Williams" <timjwilli...@comcast.net> wrote:
>
> > Does the master list contain the paths (including subfolder) ?
> > You should be able to loop through the filtered list and just copy eachof
> > the files.
> > The FileSystem object has methods for moving/copying files (add a
> > reference
> > to "Microsoft Scripting Runtime")

>
> > Tim

>
> > "KateB" <kate.e.be...@gmail.com> wrote in message

>
> >news:b80661e6-14fd-40f8-a2c0-(E-Mail Removed)....

>
> > > Hi,

>
> > > I have a many tif files (1000's) for which I have a master list in
> > > excel. I'd like to be able to filter the list & copy the filtered
> > > list of tifs to a new location (i.e. c:\NewFiles). The tif files are
> > > organised in a couple of subdirectories, which I suspect makes this
> > > harder.

>
> > > I've had a bit of a dig through the group, but haven't been able to
> > > turn anything up. Any suggestions? Using Excel 03.

>
> > > Thanks,
> > > Kate


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      12th Aug 2009
> The file is definately there

The file might be there but are you specifying the file you think you are,

> oldName = Cells(i, 1).Value


Is that the full name or merely the file name? If the latter maybe you want

oldName = strDirectory & "\" & Cells(i, 1).Value

Try the following and look at error results in the Immediate window (ctrl-g)


Sub copyFiles2()
Dim i As Long
Dim strDirectory As String
Dim strDestFolder As String
Dim oldName As String, NewName As String
Dim truncName As String

strDirectory = "c:\OldSite"
strDestFolder = "c:\test"

On Error GoTo errH
For i = 1 To 28

oldName = "": NewName = "": truncName = ""
oldName = Cells(i, 1).Value
truncName = Right(oldName, Len(oldName) - 3)
NewName = strDestFolder & "\" & truncName
Name oldName As NewName
errSkip:
Next i
Exit Sub

errH:
Debug.Print i, oldName, NewName
Resume errSkip
End Sub



I notice you named your routine "copyFiles". If that's what your really want
to do you might want to look at VBA's FileCopy function

Regards,
Peter T



"KateB" <(E-Mail Removed)> wrote in message
news:f44196d1-ebd1-424f-82a1-(E-Mail Removed)...
I tried this as a dodgy first-pass, but it's hanging on the "Name
oldName As NewName" part - it says "Run time error '53' - File not
found". The file is definately there, if I click the hyperlink in
excel, it opens up. Any ideas? The list of files starts in cell A1.

Thanks,
Kate


Sub copyFiles()
strDirectory = "c:\OldSite"
strDestFolder = "c:\test"

For i = 1 To 28

oldName = Cells(i, 1).Value
truncName = Right(oldName, Len(oldName) - 3)
NewName = strDestFolder & "\" & truncName
Name oldName As NewName

Next i


End Sub


On Aug 11, 8:54 pm, "Peter T" <peter_t@discussions> wrote:
> Look at the "Name" function, from help
>
> OldName = "C:\MYDIR\OLDFILE"
> NewName = "C:\YOURDIR\NEWFILE"
> Name OldName As NewName
>
> If not sure how to incorporate that into a loop post examples of what you
> have in cells (and cell ref's) and where you want your files to go
>
> Regards,
> Peter T
>
> "KateB" <kate.e.be...@gmail.com> wrote in message
>
> news:fa2b59ca-b7f6-4fc2-b74f-(E-Mail Removed)...
> Yes, the full path for each file is in the cell. Don't suppose you
> could give me a demo with the FileSystem object? I'm a bit of a self-
> taught hack in VBA (mostly through editing the macro recorder, but
> unfortunately that doesn't work for things outside of excel like this)
>
> Thanks!
> Kate
>
> On Aug 11, 12:29 pm, "Tim Williams" <timjwilli...@comcast.net> wrote:
>
> > Does the master list contain the paths (including subfolder) ?
> > You should be able to loop through the filtered list and just copy each
> > of
> > the files.
> > The FileSystem object has methods for moving/copying files (add a
> > reference
> > to "Microsoft Scripting Runtime")

>
> > Tim

>
> > "KateB" <kate.e.be...@gmail.com> wrote in message

>
> >news:b80661e6-14fd-40f8-a2c0-(E-Mail Removed)...

>
> > > Hi,

>
> > > I have a many tif files (1000's) for which I have a master list in
> > > excel. I'd like to be able to filter the list & copy the filtered
> > > list of tifs to a new location (i.e. c:\NewFiles). The tif files are
> > > organised in a couple of subdirectories, which I suspect makes this
> > > harder.

>
> > > I've had a bit of a dig through the group, but haven't been able to
> > > turn anything up. Any suggestions? Using Excel 03.

>
> > > Thanks,
> > > Kate



 
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
Automatically copy a big list of files in Win XP Vital Miranda Windows XP Help 2 5th Sep 2008 04:57 AM
Want to list, copy, rename files from asp on a different windows domain Jeremy Microsoft ASP .NET 0 18th Feb 2008 07:16 PM
how can I copy a list of my mp3 files from a Windows Explorer window to Word? Lisa Hetherington Windows XP General 2 7th Dec 2004 06:57 PM
Copy a list of files to Word Ricky Windows XP General 2 8th May 2004 11:04 AM
copy a list of files in a table to new directory niksto Microsoft Access VBA Modules 2 14th Dec 2003 10:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 AM.