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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:26:01+00:00 2026-05-11T00:26:01+00:00

I would like to know if it is possible to copy/move files to a

  • 0

I would like to know if it is possible to copy/move files to a destination based on the origin name.

Basically, I have a /mail folder, which has several subfolders such as cur and new etc. I then have an extracted backup in /mail/home/username that is a duplicate. mv -f will not work, as I do not have permission to overwrite the directories, but only the files within.

I get errors such as mv: cannot overwrite directory `/home/username/mail/username.com’

What I want to do is for each file in the directory username.com, move it to the folder of the same name in /mail. There could be any number of folders in place of username.com, with seperate sub sirectories of their own.

What is the best way to do this?

I have to do it this way as due to circumstances I only have access to my host with ftp and bash via php.

edit: clarification

I think I need to clarify what happened. I am on a shared host, and apparently do not have write access to the directories themselves. At least the main ones such as mail and public_html. I made a backup of ~/mail with tar, but when trying to extract it extracted to ~/mail/home/mail etc, as I forgot about the full path. Now, I cannot simply untar because the path is wrong, and I cannot mv -f because I only have write access to files, not directories.

  • 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. 2026-05-11T00:26:01+00:00Added an answer on May 11, 2026 at 12:26 am

    For copying, you should consider using cpio in ‘pass’ mode (-p):

    cd /mail; find . -type f | cpio -pvdmB /home/username/mail 

    The -v is for verbose; -d creates directories as necessary; -m preserves the modification times on the files; -B means use a larger block size, and may be irrelevant here (it used to make a difference when messing with tape devices). Omitted from this list is the -u flag that does unconditional copying, overwriting pre-existing files in target area. The cd command ensures that the path names are correct; if you just did:

    find /mail -type f | cpio -pvdmB /home/username 

    you would achieve the same result, but only by coincidence – because the sub-directory under /home/username was the same as the absolute pathname of the original. If you needed to do:

    find /var/spool/mail -type f | cpio -pvdmB /home/username/mail 

    then the copied files would be found under /home/username/mail/var/spool/mail, which is unlikely to be what you had in mind.

    You can achieve a similar effect with (GNU) tar:

    (cd /mail; tar -cf - . ) | (cd /home/username/mail; tar -xf - ) 

    This copies directories, not just files. To do that, you need GNU-only facilities:

    (cd /mail; find . -type f | tar -cf - -F - ) | (cd /home/username/mail; tar -xf - ) 

    The first solo dash means ‘write to stdout’; the second means ‘read from stdin’; the ‘-F’ option means ‘read the file names to copy from the named file’.

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

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • 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
  • added an answer Same as I would for numbers. I'd declare constants of… May 11, 2026 at 8:58 am
  • added an answer There are probably a few minor performance improvements and bug… May 11, 2026 at 8:58 am
  • added an answer Not that I know of, but the short-tag plus the… May 11, 2026 at 8:58 am

Related Questions

I would like to know if I can open 2 different diagrams using MS
I would like to know if there is any way to add custom behaviour
I would like to know if there is some way to share a variable
I would like to know if there are general rules for creating an index
I would like to know if there is a way to disable automatic loading
I would like to know if there is an easy way to detect if
I would like to know if it is possible to determine if a function
I would like to know if I can install say Visual Studio 2008 Pro
I would like to know if it is possible, To extract the userid from
I would like to know if it is possible, to select certain columns from

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.