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

  • SEARCH
  • Home
  • 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 7858357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:23:44+00:00 2026-06-02T21:23:44+00:00

I was thinking something like what I’m trying to accomplish could be done with

  • 0

I was thinking something like what I’m trying to accomplish could be done with built in shell tools w/o the need for a more complicated script.

I’d like to find all the files in a path and copy them to a destination basepath retaining the relative paths they were found in.

Example:

Say I ran:

[~:] find /path/src  \( -name "*.jpg" -o -name "*.gif" \) 

and that returned:

/path/src/a.jpg
/path/src/dir1/b.jpg
/path/src/dir2/dir3/c.gif

I’d like them to all end up in:

/path/dest/a.jpg
/path/dest/dir1/b.jpg
/path/dest/dir2/dir3/c.gif

I tried an -exec cp {} /path/dest \; flag to find but that just dumped everything in /path/dest. E.g:

/path/dest/a.jpg
/path/dest/b.jpg
/path/dest/c.gif
  • 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-06-02T21:23:47+00:00Added an answer on June 2, 2026 at 9:23 pm

    You can use rsync for this, e.g.

    $ rsync -avm /path/src/ /path/dest/ --include \*/ --include \*.jpg --include \*.gif --exclude \*
    

    Just to clarify the above:

    -avm             # recursive, copy attributes etc, verbose, skip empty directories
    /path/src/       # source
    /path/dest/      # destination (NB: trailing / is important)
    --include \*/    # include all directories
    --include \*.jpg # include files ending .jpg
    --include \*.gif # include files ending .gif
    --exclude \*     # exclude all other files
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could mapreduce be used to implement a webserver? I'm thinking something like when a
Is it possible to define an object within another object? I'm thinking something like
I am thinking about something like this: public static <T extends Comparable<T>> T minOf(T...ts){
I'm thinking of something like gnugo 's ascii interface. I'd think of the turns
I was thinking about making something like Linq for Lua, and I have a
So, I was thinking of doing something like this: zones#show /map/map_id/zones/zone_id And this: zones#index
I have just done something without thinking it through. I have made a branch
How can I implement a foreign key in SQLite? I was thinking something like
So, I was thinking I could just loop through localStorage like a normal object
I was thinking something like this: url = models.CharField(max_length=2047) Is there a solution that

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.