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
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, Version 25H2 (OS Build 26200.7171)
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1402a (x64), Everything Toolbar 2.1.0, Listary Pro 6.3.6.99
Portable x64 XYplorer (Actual version, including betas)
Display settings 1920 x 1080 Scale 100%
Everything 1.5.0.1402a (x64), Everything Toolbar 2.1.0, Listary Pro 6.3.6.99
XYplorer Beta Club