Author Posts

March 2, 2017 at 7:25 am

Hey,
i want to copy a file in specific folders
the folder name can chance due to different versions of the software.
org.xmind.ui.resources_*VERSION*
org.xmind.ui.resources_3.7.0.201612151837

in every of this Folders org.xmind.ui.resources_*
i want my file to be copied.
Ist there an easy way to make this possible
Thanks in advance.

March 2, 2017 at 9:00 am

basically i want him to check if there is folders with this name and then copy my file into them
but not only into them
my file need to be in a subfolder
org.xmind.ui.resources_3.7.0.201612151837\templates\myfile

so powershell should check for folders with that name to then copy my file into the template subfolder of those he found.

March 2, 2017 at 10:29 am

Hi,

You can use this script to check the folder and overwrite the existing file if present.

$sourcefile = 'c:\test\file.txt'
$destinationroot = Get-ChildItem -Path c:\org.xmind.ui.resources_* -Directory

If (Test-Path -Path $destinationroot) 
{
	$destinationfolder = "$destinationroot\templates\myfile"

	Copy-Item -Path $sourcefile -Destination $destinationfolder -Force
}

good luck,
Albert