Page 1 of 1
Backup images but exclude some folders
Posted: 20 Apr 2026 11:09
by kiwichick
I'd like to create a backup (or sync if that is more appropriate) of images in a series of folders while maintaining the folder structure - except for folders named subs (which don't contain any images). I've got the following code to work for backing up the images but I can't figure out how to exclude the subs folders. Is it possible?
Code: Select all
backupto "Z:\delee\Pictures\_Media Artwork\test", "Q:\ABBA DVDs, Documentaries, etc", "2", "1", "0", "0", "0", "0", "1", "*.jpg|*.jpeg|*.png", "2";
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 11:20
by highend
You can exclude files in \subs but not creating the folder in the target location itself:
"*.jpg|*.jpeg|*.png|-*\subs\*"
You could create a file list list first and exclude the folders there and use that for the source though...
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 11:47
by kiwichick
highend wrote: ↑20 Apr 2026 11:20
"*.jpg|*.jpeg|*.png|-*\subs\*"
Thanks but it didn't work. I still get an empty subs folder.
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 11:48
by highend
Read my post again?
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 11:52
by kiwichick
highend wrote: ↑20 Apr 2026 11:20
but not creating the folder in the target location itself
Am I misunderstanding what that means?
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 12:10
by highend
You will get the \subs folder, create a file list first (with \subs excluded) and supply that to the backupto command
E.g.:
Code: Select all
$source = "Q:\ABBA DVDs, Documentaries, etc";
$items = quicksearch("*.jpg;*.jpeg;*.png", $source, , "s");
$result = writefile("%TEMP%\source.txt", formatlist($items, "f", <crlf>, "!*\subs\*"), , "tu");
backupto "Z:\delee\Pictures\_Media Artwork\test", "*%TEMP%\source.txt", "2", "1", "0", "0", "0", "0", "1", , "2";
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 12:35
by kiwichick
highend wrote: ↑20 Apr 2026 12:10
You will get the \subs folder, create a file list first (with \subs excluded) and supply that to the backupto command
E.g.:
Code: Select all
$source = "Q:\ABBA DVDs, Documentaries, etc";
$items = quicksearch("*.jpg;*.jpeg;*.png", $source, , "s");
$result = writefile("%TEMP%\source.txt", formatlist($items, "f", <crlf>, "!*\subs\*"), , "tu");
backupto "Z:\delee\Pictures\_Media Artwork\test", "*%TEMP%\source.txt", "2", "1", "0", "0", "0", "0", "1", , "2";
That gave me no folders at all - not even the source folder (ABBA DVDs, Documentaries, etc). I think maybe I left out information that would make things clearer. The folder structure is like this:
Q:
ABBA DVDs, Documentaries, etc
ABBA The Movie (1977)
subs
backdrop.jpg
folder.png
logo.png
The Golden Years (2007)
subs
folder.jpg
backdrop.png
I want the folder structure to be maintained but without subs.
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 12:58
by admin
Try this: "*.jpg|*.jpeg|*.png|-subs\"
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 13:23
by highend
It doesn't work, @Don
Then (if this shouldn't get fixed) do it the easy way?
Code: Select all
$dst = "Z:\delee\Pictures\_Media Artwork\test";
setting "BackgroundFileOps", 0;
backupto $dst, "Q:\ABBA DVDs, Documentaries, etc", "2", "1", "0", "0", "0", "0", "1", "*.jpg|*.jpeg|*.png", "2";
delete 1, 0, quicksearch("*\subs* /d", $dst);
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 14:03
by admin
It doesn't work ... how?
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 14:12
by highend
Nothing at all will be copied^^
The only thing that happens is that the destination folder will be created
Script to replicate:
Code: Select all
$dst = "C:\Temp\dst";
$src = "C:\Temp\src";
new("$src\subs", "dir");
new("$src\a.jpg", "file");
new("$src\subs\b.jpg", "file");
backupto $dst, $src, "2", "1", "0", "0", "0", "0", "1", "*.jpg|*.jpeg|*.png|-subs\", "2";
Do it with
Code: Select all
backupto $dst, $src, "2", "1", "0", "0", "0", "0", "1", "*.jpg|*.jpeg|*.png|-*\subs\*", "2";
and it still creates the \subs folder but at least doesn't copy over the .jpg file from that folder
Re: Backup images but exclude some folders
Posted: 20 Apr 2026 15:47
by admin
Interesting case!
1) SC backupto is the wrong choice here because the source parameter expects an item or a list of items which are then checked against the filter, not a folder whose contents are checked against the filter.
2) SC sync is the right choice, but it has a bug in the filter (as old as the filter parameter itself!) which makes it fail at the OP's task as well. It will be fixed in the next beta:
Code: Select all
! SC backupto, SC sync: The "filter" parameter excluded all subfolders if it contained
any file patterns. Fixed. Now, for example, the filter "*.bas|*.ini|*.txt|-appdata\"
only allows BAS, INI, and TXT files to pass through, as well as all folders except
those called "appdata", just as expected.
After the fix is uploaded, this should work for the OP:
Code: Select all
sync "Q:\ABBA DVDs, Documentaries, etc", "Z:\delee\Pictures\_Media Artwork\test", 1, 0, 0, "bckn", 7:="*.jpg|*.jpeg|*.png|-subs\";
Re: Backup images but exclude some folders
Posted: 21 Apr 2026 06:59
by kiwichick
admin wrote: ↑20 Apr 2026 15:47
After the fix is uploaded, this should work for the OP:
Code: Select all
sync "Q:\ABBA DVDs, Documentaries, etc", "Z:\delee\Pictures\_Media Artwork\test", 1, 0, 0, "bckn", 7:="*.jpg|*.jpeg|*.png|-subs\";
Thank you so much, Don. That works great. I tweaked the code so that the target folder was named the same as the source folder (ie: ABBA DVDs, Documentaries, etc) and now it's perfect.