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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:45:31+00:00 2026-05-31T18:45:31+00:00

I have one folder with about 1000 files and I want to group them

  • 0

I have one folder with about 1000 files and I want to group them according to their resepctive parent folders.

I did ls- R > updated.txt to get the original setup of folders and files.

The updated. txt looks like this:

./Rhodococcus_RHA1:
NC_008268.fna
NC_008269.fna
NC_008270.fna
NC_008271.fna

./Rhodoferax_ferrireducens_T118:
NC_007901.fna
NC_007908.fna

./Rhodopseudomonas_palustris_BisA53:
NC_008435.fna

./Rhodopseudomonas_palustris_BisB18:
NC_007925.fna

./Rhodopseudomonas_palustris_BisB5:
NC_007958.fna

./Rhodopseudomonas_palustris_CGA009:
NC_005296.fna
NC_005297.fna

So, by looking at this file, I know what files go into what folder. The folder with all the 1000 files together looks like this:

results_NC_004193.fna.1.ebwt.map
results_NC_004307.fna.1.ebwt.map
results_NC_004310.fna.1.ebwt.map
results_NC_004311.fna.1.ebwt.map
results_NC_004337.fna.1.ebwt.map
results_NC_004342.fna.1.ebwt.map
results_NC_004343.fna.1.ebwt.map
results_NC_004344.fna.1.ebwt.map

and so on…

You can see that the filenames of all the 1000 files are dependent on their original names in the folder setup(if that’s a good way to explain it).

I want to move these results_XXXXXXXX files to folders (have to create new folders) with the original setup. So it should be something like this:

./Rhodococcus_RHA1: (this is a folder)
results_NC_008268.fna.1.ebwt.map 
results_NC_008269.fna.1.ebwt.map
results_NC_008270.fna.1.ebwt.map
results_NC_008271.fna.1.ebwt.map

./Rhodoferax_ferrireducens_T118:
results_NC_007901.fna.1.ebwt.map
results_NC_007908.fna.1.ebwt.map

I don’t really know how to do this… maybe some kind of mov command? I’d appreciate help with this problem.

  • 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-31T18:45:32+00:00Added an answer on May 31, 2026 at 6:45 pm

    Run the following command from the folder where you have those 1000 files. The path/to/original/files is the path to the original files (the one that you did ls -R). you should get a list of mv commands. Verify several of them to confirm that those are correct. If so, add | sh next the command and rerun it to execute those commands. If you don’t have all the corresponding files in the 1000 files folder, you would get mv commands that would return “file not found”, that can be ignored or piped to /dev/null. This assumes that you always have a file in original folder so that it knows where to move the file. If not, some of those 1000 files won’t be moved. As always, take a good backup before you do this.

    find path/to/original/files -type f | awk -F"/" '{ path=$0; sub($NF, "", path); printf("mv results_%s.1.ebwt.map \"%s\"\n", $NF, path);}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Folder with about 1000 Projects . So to open one, it's
I have about 2000 subfolders in one folder, in each of these folders there
Suppose i have one folder and inside that another two files are there .
I have one solution with 3 folders (Forms, Notices, Reports). In the Notice folder
I have three files in a folder 'test' one.php two.php print.html And i have
I have unfortunately committed one big folder to SVN (it has about 1.4GB and
I have one folder synced between two computers (using one of online sync tools).
I have one created one folder called MYFOLDER inside my folder in have one
I have created one library project in iphone and my images folder is present
should i after i have created a svn repo, import one project folder into

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.