--Exclude-From File Not Working (But -Exclude Does)

Hi all,

I'm presently trying to move a number of directories and folders from a Windows server to a Google Cloud Storage Bucket, but in testing locally on the Windows server first, I've come to the conclusion I need to make use of the '--exclude-from' flag to exclude specific folders. However, this doesn't seem to be working for me at all.
My PowerShell script is below:

$Exclusions = @(
"/Stay1/**",
"/Stay2/**"
)
$ExcludeFile = "C:\rclone\rclone_exclusions.txt"
#$Exclusions | Out-File $ExcludeFile
$RClone = "C:\rclone\rclone.exe"
$Source = "C:\Users\User\Downloads"
$Destination = "C:\Users\User\MoveTo"
."$RClone" move $Source $Destination --exclude-from $ExcludeFile

However, this seems to completely ignore $ExcludeFile.
If I run
."$RClone" move $Source $Destination --exclude "/Stay1/**" --exclude "/Stay2/**", then it works perfectly.

The question is: what am I doing wrong here? Is it perhaps the way Windows writes the file?
Any help would be greatly appreciated!

I wonder... Does the file have CR LF line endings? I wonder if rclone is interpreting those...

Can you run your failing command with -vv --dump filters and post the result of the dumped filters? That should tell us what is going on.

OK, here's the result of the dumped filters, as requested:

--- start filters ---
--- File filter rules ---
- (^|/)��/ S t a y 1 / [^/]* [^/]* 
 $
- (^|/) / S t a y 2 / [^/]* [^/]* 
 $
- (^|/) $
--- Directory filter rules ---
--- end filters ---
2019/09/25 09:45:03 DEBUG : rclone: Version "v1.36" starting with parameters ["C:\\rclone\\rclone.exe" "move" "C:\\Users\\User\\Downloads" 
"C:\\Users\\User\\MoveTo" "--exclude-from" "C:\\rclone\\rclone_exclusions.txt" "-vv" "--dump-filters"]
2019/09/25 09:45:03 INFO  : Local file system at \\?\C:\Users\User\MoveTo: Modify window is 100ns
2019/09/25 09:45:03 INFO  : Test3.txt: Moved (server side)
2019/09/25 09:45:03 INFO  : Stay2/Test2.txt: Moved (server side)
2019/09/25 09:45:03 INFO  : Local file system at \\?\C:\Users\User\MoveTo: Waiting for checks to finish
2019/09/25 09:45:03 INFO  : Local file system at \\?\C:\Users\User\MoveTo: Waiting for transfers to finish
2019/09/25 09:45:03 INFO  : Stay1/Test1.txt: Moved (server side)
2019/09/25 09:45:03 INFO  : 
Transferred:      0 Bytes (0 Bytes/s)
Errors:                 0
Checks:                 0
Transferred:            3
Elapsed time:          0s
2019/09/25 09:45:03 DEBUG : Go routines at exit 3
2019/09/25 09:45:03 DEBUG : rclone: Version "v1.36" finishing with parameters ["C:\\rclone\\rclone.exe" "move" "C:\\Users\\Userw\\Downloads" 
"C:\\Users\\User\\MoveTo" "--exclude-from" "C:\\rclone\\rclone_exclusions.txt" "-vv" "--dump-filters"]

It doesn't even seem to be trying to read the exclusion file from what I can see above.
The exclusions file specifically has:
/Stay1/**
/Stay2/**
That means Stay2/Test2.txt and Stay1/Test1.txt should not be moved (or at least, that is what I'm trying to accomplish).

By the look of your filters, the file you've written is encoded in UTF-16 with BOM. Can you write a plain text file in UTF-8 or ASCII (without BOM) - that should work.

1 Like

Thanks very much!
Using $Exclusions | Out-File $ExcludeFile -Encoding ascii worked brilliantly!

I also updated the version of rclone so I could run the additional command to clean up the empty directories it was leaving behind:
."$RClone" move $Source $Destination --delete-empty-src-dirs --exclude-from $ExcludeFile

Thanks again for the swift help :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.