I need a way to put a new file in many folders on the same drive. Does windows 7 have a native way of handling thisor is there a batch method or some other way? My system is Windows 7 SP1 64bit.

My existing folder structure is: C:\Companyname\Companyname jobs\job

Each job folder has the name format: clientname_someplace.067

Within each folder is a subfolder - quotes invoices.hours.tc

How do I a traverse all job folders to propagate or distribute a new file to each quotes invoices.hours.tc subfolder?

the filetypes I want to distribute could be anything but are generally excel files (.xlsm), .txt files and open office files (.odt files).

  • As you suggest, use a batch file. For will probably be your friend if you wish to make it dynamic. – Ƭᴇcʜιᴇ007 Apr 1 '14 at 20:50

Get a batch or Powershell script to iterate through the directory structure, check the name of the current folder, if it fits, copy the files. Here is a Powershell example, careful, it iterates through the whole drive, adapt it to your particular needs!:

$targetdir = "C:\company\CompanyJobs\0jobTest\" + "whatever\you\need\to\concatenate"
$dirs = Get-ChildItem -Directory -Recurse $targetdir
foreach ($d in $dir){
    if ($d.Name -eq "quotes invoices.hours.tc")
            # could also be: -like "quotes invoices.*"
            Copy-Item -Path c:\path\to\source\file.xlsx -Destination $d.FullName
  • Thanks, I'll go away and think about that, I suppose I can insert any path after Recurse? e.g. C:\Companyname\Companyname jobs\ – nigelc Apr 2 '14 at 2:11
  • Yes, if your path contains spaces enclose it in quotes. – TheUser1024 Apr 2 '14 at 7:08
  • I tried the above script and got an error: Get-ChildItem : A parameter cannot be found that matches parameter name 'c'. At line:1 char:34 + $dirs = Get-ChildItem -Directory -c:\company\CompanyJobs\0jobTest\ + ~~~ + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand – nigelc Apr 5 '14 at 20:50
  • @nigelc: try concatenating your folder string in a variable and pass that to get-childitem – TheUser1024 Apr 5 '14 at 21:11
  • Hmmm - Thanks but what does that mean? I've had a good hunt around about concatenation in powershell and haven't found anything that looks right - I know this site doesn't exist for 'recipe' requests but it'd take me a month of sundays to work that out – nigelc Apr 8 '14 at 1:07

One way would be to create symbolic links. Here is an article that discusses one way to do it: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux.

link="C:\Companyname\Companyname jobs\job\file.xls"
target="C:\Companyname\Companyname jobs\job2\file.xls"
mklink /D $link $target
  • Thanks Axe - I hadn't heard of those, they will be very useful, but in this case once I distribted the files I will then modify them – nigelc Apr 2 '14 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.