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 6928261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:09:48+00:00 2026-05-27T11:09:48+00:00

I am making a file sync program. In order to increase the efficiency of

  • 0

I am making a file sync program. In order to increase the efficiency of the syncs, I have it sync/copy over only the new files/folders from the source. Anyway, when I copy directories into the sync I use ‘cp pR itemName, because it preserves the attributes of the directory and the icon (if it is present). But, unfortunately it also copies all of the contained files in that directory… I do not want the children copied (excepting some invisible files), I want to copy one item at a time. Is there a way that I can programatically copy a directory, by itself (without including it’s child files) but still retaining it’s attributes (like Date Created and icon)?

  • 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-27T11:09:49+00:00Added an answer on May 27, 2026 at 11:09 am

    You want to use rsync.
    Rsync creates a list of all the files and copies only the ones that have been modified. This is really fast.
    i do

    rsync -avzr filesIwant WhereItShouldGo
    

    but, to answer your question, you can list the fils and exclude one you dont want with grep and using xargs, run your action.
    lets say you ran ls and this is what you got

    #:~ cy$ ls
    BackEnd         Downloads       Pictures
    CSC 130         Library         Public
    Checkbook.java      Movies          Site and Code
    Desktop         Music           Sites
    Documents       NetBeansProjects
    

    and lets say that you wanted everything, just not anything in the music folder or the movies folder
    you can do:

    #:~ cy$ ls | grep -v Music | grep -v Movies
    BackEnd
    CSC 130
    Checkbook.java
    Desktop
    Documents
    Downloads
    Library
    NetBeansProjects
    Pictures
    Public
    Site and Code
    Sites
    

    notice movies and Music were not listed. Well now you can run xargs and do the action. Since i dont want to delete anything, im not gonna do it, but this is what it would look like

    #:~ cy$ ls | grep -v Music | grep -v Movies| xargs -I xx cp xx  ToSomePlace
    

    the -I command for xargs takes the input from the last command, and gives it a nickname, in my case “xx” so that you can call commands on xx knowing that they are each an element of the last command. Hope that helped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i making a file transfer (server-client) application .. i have two listviewS to explore
I'm making a file edit interface in my web-app, I have a textarea with
I'm making a file transfer application between (client-server) and have the tools I need
I have a habit of making file backups by adding the .bak extension (file.ext.bak).
I am having trouble making a file, I think I have got the majority
I am making a CSS file for an XML document. I need to insert
Is is possible to prevent Wget from making an output file when there is
I am making a litte php-file to log some ip addresses. It is going
I am making a POST to another php file that I want to render
I'm making a page where the user upload a file. I want an if

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.