Hello! I searched forum and haven't found anything that meets my criteria, and I'm complete noob at scripting, so here I am.
I want to make backups of selected files in Backups folder with names changed to meet a key. Basically:
I highlight files, for example:
C:/Files/Home_picture.jpg
C:/Files/Program.exe
Script creates folder in that root called Backups
C:/Files/Backups
Copies selected files, and pastes them in Backups folder with changed names meeting a key [filename_backup.extension], for example
C:/Files/Backups/Home_picture_backup.jpg
C:/Files/Backups/Program_backup.exe
If i select new files and folder Backups already exist in their folder, it copies inside it instead.
I hope something like this could be done. Thanks in advance!
Make backups in one folder with changed names
Re: Make backups in one folder with changed names
Code: Select all
$items = <get SelectedItemsNames <crlf>>;
$subExists = (exists("<curpath>\Backup") == 2) ? 1 : 0;
if (!$subExists) { new("Backup", "dir"); }
foreach($item, $items, <crlf>, "e") {
if (exists($item) == 2) { continue; }
// Backup subfolder already exists
if ($subExists) {
copyitem "<curpath>\$item", "<curpath>\Backup\$item";
// Backup subfolder doesn't exist
} else {
copyitem "<curpath>\$item", "<curpath>\Backup\" . gpc($item, "base") . "_backup" . "." . gpc($item, "ext");
}
}
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de
Re: Make backups in one folder with changed names
Thank you very much! Works like a charm
Last edited by Alter on 23 Feb 2021 07:58, edited 1 time in total.
Re: Make backups in one folder with changed names
Why not making something like _date_time instead of _backup.
Then you can have multiple versions of each file in the backup sub-dir.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3235)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69