Powershell Basic

This topic contains 2 replies, has 2 voices, and was last updated by  Albert van Boerum 1 year ago.

  • Author
  • #65538

    i want to copy a file in specific folders
    the folder name can chance due to different versions of the software.

    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.

  • #65553

    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

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

  • #65562

    Albert van Boerum


    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,

You must be logged in to reply to this topic.