PC Review


Reply
Thread Tools Rate Thread

Copy files in sub folders to a specific directory

 
 
andreashermle
Guest
Posts: n/a
 
      27th Jun 2010
Dear experts:

I got more than 50 subfolders located under the following main
folder's path:

C:\test\MainFolder\...
....SubFolder_1
....SubFolder_2
....SubFolder_3
....SubFolder_4
....SubFolder_n

There is (1) one xlsx-file in every subfolder.

I now would like to be able via a Macro to copy the xlsx-files located
in the sub folders directly into the following directory:

C:\test\MainFolder.

Is this feasible?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      28th Jun 2010
You can use the Name function, from help
Name oldpathname As newpathname

something like this, untested!

s1 = C:\test\MainFolder\SubFolder_#\myFile.xls"
s2 = C:\test\MainFolder\myFile"

for i = 1 to 50
sOld = replace(s1, "#", cStr(i))
sNew = s2 & "myFile_" & right("0" & i, 2) & ".xls"
Name sOld as sNew
Next

Regards,
Peter T


"andreashermle" <(E-Mail Removed)> wrote in message
news:bbc09306-a044-4a1b-96bc-(E-Mail Removed)...
> Dear experts:
>
> I got more than 50 subfolders located under the following main
> folder's path:
>
> C:\test\MainFolder\...
> ...SubFolder_1
> ...SubFolder_2
> ...SubFolder_3
> ...SubFolder_4
> ...SubFolder_n
>
> There is (1) one xlsx-file in every subfolder.
>
> I now would like to be able via a Macro to copy the xlsx-files located
> in the sub folders directly into the following directory:
>
> C:\test\MainFolder.
>
> Is this feasible?
>
> Help is much appreciated. Thank you very much in advance.
>
> Regards, Andreas


 
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
Modify Ron de Bruin Code; Save Specific Files to Specific Folders ryguy7272 Microsoft Excel Programming 1 24th Aug 2010 05:21 PM
Help to copy files names in a column from one directory to another directory VBA Paul B Microsoft Excel Programming 4 10th Nov 2008 01:54 AM
Would like to write batch file to copy all TXT files in a given directory and all subdirectories to a single target directory. Rob Windows XP General 5 20th Aug 2007 02:42 PM
copy a file to a specific user profile directory in the installati =?Utf-8?B?Z2hvYmxleQ==?= Microsoft VB .NET 3 26th May 2005 02:48 PM
Copy all files and sub-directory under a specific directory Phil Microsoft Access 1 20th Dec 2003 11:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:28 AM.