Backup images but exclude some folders

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
kiwichick
Posts: 673
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Backup images but exclude some folders

Post 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";
Windows 10 Pro 22H2

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Backup images but exclude some folders

Post 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...
One of my scripts helped you out? Please donate via Paypal

kiwichick
Posts: 673
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Backup images but exclude some folders

Post 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.
Windows 10 Pro 22H2

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Backup images but exclude some folders

Post by highend »

Read my post again?
One of my scripts helped you out? Please donate via Paypal

kiwichick
Posts: 673
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Backup images but exclude some folders

Post 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?
Windows 10 Pro 22H2

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Backup images but exclude some folders

Post 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";
One of my scripts helped you out? Please donate via Paypal

kiwichick
Posts: 673
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Backup images but exclude some folders

Post 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.
Windows 10 Pro 22H2

admin
Site Admin
Posts: 66070
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Backup images but exclude some folders

Post by admin »

Try this: "*.jpg|*.jpeg|*.png|-subs\"

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Backup images but exclude some folders

Post 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);
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66070
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Backup images but exclude some folders

Post by admin »

It doesn't work ... how?

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Backup images but exclude some folders

Post 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
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66070
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Backup images but exclude some folders

Post 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\";

kiwichick
Posts: 673
Joined: 08 Aug 2012 04:14
Location: Windows 10 Pro 22H2, 150% scaling

Re: Backup images but exclude some folders

Post 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.
Windows 10 Pro 22H2

Post Reply