chriskyfung/My-PowerShell-Scripts

๐Ÿ› Backup files automatically removed by TheBrain program

chriskyfung opened this issue ยท 1 comments

Problem

TheBrain program deletes all the backup files made by the PowerShell script after a certain period of time.

Suggestion

Save the backup files in a separate path instead of the node directories. This way, the software program will not delete them and you can access them whenever you need.

Here is a PowerShell script that copies a file to a non-existing folder path:

Copy-Item -Path "C:\path\to\file" -Destination (New-Item -ItemType Directory -Force -Path "C:\path\to\non-existing\folder") -Force

Replace C:\path\to\file with the path of the file you want to copy and C:\path\to\non-existing\folder with the path of the non-existing folder you want to copy the file to. The -Force parameter ensures that the folder is created if it does not exist.

(1) Copy a single file to a non-existing folder - Stack Overflow. https://stackoverflow.com/questions/9297027/copy-a-single-file-to-a-non-existing-folder.
(2) How To Copy a File or Folder to a New Destination using Powershell. https://www.danielengberg.com/powershell-copy-a-file-to-a-directory-that-does-not-exist/.
(3) Powershell command to copy entire folder and contents to a different .... https://superuser.com/questions/1504396/powershell-command-to-copy-entire-folder-and-contents-to-a-different-folder.