Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 480617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:54:40+00:00 2026-05-13T00:54:40+00:00

As you can see in the title I try to sync a folder with

  • 0

As you can see in the title I try to sync a folder with a list of files. I hoped that this command would delete all files in dest/ that are not on the list, but it didn’t.

So I searched a little bit and know now, that rsync can’t do this.

But I need it, so do you know any way to do it?

PS: The list is created by a python script, so it is imaginable that your solution uses some python code.

EDIT, let’s be concrete:

The list looks like this:

/home/max/Musik/Coldplay/Parachutes/Trouble.mp3
/home/max/Musik/Coldplay/Parachutes/Yellow.mp3
/home/max/Musik/Coldplay/A Rush of Blood to the Head/Warning Sign.mp3
/home/max/Musik/Coldplay/A Rush of B-Sides to Your Head/Help Is Around the Corner.mp3
/home/max/Musik/Coldplay/B-Sides (disc 3)/Bigger Stronger.mp3

and the command like this:

rsync --delete --files-from=/tmp/list / /home/max/Desktop/foobar/

This works, but if I delete a line, it is not deleted in foobar/.

EDIT 2:

rsync -r --include-from=/tmp/list --exclude=* --delete-excluded / /home/max/Desktop/foobar/

That works neither …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:54:40+00:00Added an answer on May 13, 2026 at 12:54 am

    Perhaps you could do this using a list of include patterns instead, and use --delete-excluded (which does as the name suggests)? Something like:

    rsync -r --include-from=<patternlistfile> --exclude=* --delete-excluded / dest/
    

    If filenames are likely to contain wildcard characters (*, ? and [) then you may need to modify the Python to escape them:

    re.sub("([[*?])", r"\\\1", "abc[def*ghi?klm")
    

    Edit: Pattern-based matching works slightly differently to --files-from in that rsync won’t recurse into directories that match the exclude pattern, for reasons of efficiency. So if your files are in /some/dir and /some/other/dir then your pattern file needs to look like:

    /some/
    /some/dir/
    /some/dir/file1
    /some/dir/file2
    /some/other/
    /some/other/dir/
    /some/other/dir/file3
    ...
    

    Alternatively, if all files are in the same directory then you could rewrite the command slightly:

    rsync -r --include-from=<patternlistfile> --exclude=* --delete-excluded /some/dir/ dest/
    

    and then your patterns become:

    /file1
    /file2
    

    Edit: Thinking about it, you could include all directories with one pattern:

    /**/
    

    but then you’d end up with the entire directory tree in dest/ which probably isn’t what you want. But combining it with -m (which prunes empty directories) should solve that – so the command ends up something like:

    rsync -m -r --delete-excluded --include-from=<patternfile> --exclude=* / dest/
    

    and the pattern file:

    /**/
    /some/dir/file1
    /some/other/dir/file3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 242k
  • Answers 242k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have recently implemented DAWG for a wordgame playing program.… May 13, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer Math.Ceiling(a_variable) May 13, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer Camera depth should be relative to the layer -- I.E.,… May 13, 2026 at 7:43 am

Related Questions

I have been utilizing Scott Gu's tutorials on LINQ to SQL to try to
I have a solution with many projects. One project contain few custom components. One
I have included a resource in my Visual Studio 2005 solution that was a
I build a website focussing on loading only data that has to be loaded.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.