Rclone - Find destination folder automatically based on filenames at upload to ftp

What is the problem you are having with rclone?

I have to upload around 40-50 piece of files (same extensions) to ftp, every day, to separated folders, where those file belongs.
Im, complete newbie in scripting, I just got to know rclone and it's amazing what it can do.
So I'm wondering is there any script to reclone to find out destination folder automatically for files to be uploaded, based on their names? More precisely based on the numbers in the file name:

Filenames 2nd and 3rd number are the same as destination folders last two digits,
Destination folders are in different places, but under the same root folder.

Is there any way to ask rclone to check the 2nd and 3rd character of each files waiting to be uploaded, and based on that two numbers, upload it to the a directory where these two numbers are listed.

For example:

  • 50321_XXXXX.txt -----goes_to-----ftp:/xxxx/yyyy/zzzz/nn03/
  • 51124_XXXXX.txt -----goes_to-----ftp:/xxxx/wwww/kkkk/nn11/
  • 53413_XXXXX.txt -----goes_to-----ftp:/xxxx/dddd/aaaa/nn34/

Could you help me with where to go?

Thank you for your answers.

Run the command 'rclone version' and share the full output of the command.

rclone v1.60.1

  • os/version: darwin 10.15.7 (64 bit)

  • os/kernel: 19.6.0 (x86_64)

  • os/type: darwin

  • os/arch: amd64

  • go/version: go1.19.3

  • go/linking: dynamic

  • go/tags: cmount

Which cloud storage system are you using? (eg Google Drive)

FTP, Google drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Paste command here

The rclone config contents with secrets removed.

Paste config here

A log from the command with the -vv flag

Paste  log here

hello and welcome to the forum,

need to create a remote for the ftp server - https://rclone.org/ftp/
let's call that remote ftp

and then could try using filters
rclone copy /path/to/source ftp:/xxxx/yyyy/zzzz/nn03/ --include={{\d03\d\d_.*.txt}} --dry-run

tho easier to test using rclone ls, as that does not copy files, just lists the files that would be copied

rclone ls d:\source 
        1 50321_XXXXX.txt
        1 51124_XXXXX.txt
        1 53413_XXXXX.txt
        1 a0321_XXXXX.txt

rclone ls d:\source --include={{\d03\d\d_.*.txt}} 
        1 50321_XXXXX.txt

rclone ls d:\source --include={{\d11\d\d_.*.txt}} 
        1 51124_XXXXX.txt

rclone ls d:\source --include={{\d34\d\d_.*.txt}} 
        1 53413_XXXXX.txt

Hi, thank you for your reply. The regex filter does not works for me. "no matches found". :slight_smile:
Anyway this is a good clue that I can start with.

might need to enclose with single quotes
`--include='{{\d03\d\d_.*.txt}} '

HI, i have to correct myself:

Filter work's well on windows/CMD but does not on Mac terminal. And unfortunately, that's exactly what I need.

got bquote> in terminal. Whatever that means :slight_smile:

have to post the commands and full output, as i cannot see into your screen.

running on ubuntu

touch 50321_XXXXX.txt
rclone ls .
        0 50321_XXXXX.txt
rclone ls . --include={{\d03\d\d_.*.txt}}
rclone ls . --include='{{\d03\d\d_.*.txt}}'
        0 50321_XXXXX.txt
rclone ls . --include="{{\d03\d\d_.*.txt}}"
        0 50321_XXXXX.txt

User error. Your Filter works well. Thanks.

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