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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:50:16+00:00 2026-05-27T13:50:16+00:00

I have a folder called week1, and in that folder there are about ten

  • 0

I have a folder called “week1”, and in that folder there are about ten other folders that all contain multiple files, including one called “submit.pdf”. I would like to be able to copy all of the “submit.pdf” files into one folder, ideally using Terminal to expedite the process. I’ve tried cp week1/*/submit.pdf week1/ as well as cp week1/*/*.pdf week1/, but it had only been ending up copying one file. I just realized that it has been writing over each file every time which is why I’m stuck with one…is there anyway I can prevent that from happening?

  • 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-27T13:50:17+00:00Added an answer on May 27, 2026 at 1:50 pm

    You don’t indicate your OS, but if you’re using Gnu cp, you can use cp week1/*/submit.pdf --backup=t week/ to have it (arbitrarily) number files that already exist; but, that won’t give you any real way to identify which-is-which.

    You could, perhaps, do something like this:

     for file in week1/*/submit.pdf; do cp "$file" "${file//\//-}"; done
    

    … which will produce files named something like “week1-subdir-submit.pdf”

    For what it’s worth, the "${var/s/r}" notation means to take var, but before inserting its value, search for s (\/, meaning /, escaped because of the other special / in that expression), and replace it with r (-), to make the unique filenames.

    Edit: There’s actually one more / in there, to make it match multiple times, making the syntax:

                 "${ var           /        /                 \/  /      -    }"
                     take "var"    replace  every instance of /   with   -
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one folder called 'Data' that contains all files with current date in
I have a folder called foo. Foo has some other folders which might have
I have a cache-like folder (called minified) that holds minified css files. The files
say that i have a project which lies in a folder called 'bin', and
I have a folder, called files. It's already in the repository. Now, new files
I have a folder called notes, naturally they will be categorized into folders, and
Right now I have a folder called holding zone on my desktop, so that
In my site I have a folder called module . It has two sub-folders
In my android project, I have a folder called layout to store all xml
Assume I have a folder called C:\Program Files\Java and a folder called C:\Users\Public. I

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.