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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:26:58+00:00 2026-06-02T09:26:58+00:00

i have to move some files from a directory to another one, but this

  • 0

i have to move some files from a directory to another one, but this is a bit tricky.

here is my folder structure

/var/www/media_test1/media001/001_pm_001.jpg
                              th001_pm_001.jpg

/var/www/media_test1/media002/002_pm_001.jpg
                              th002_pm_001.jpg

/var/www/media_test1/media003/003_pm_001.jpg
                              th003_pm_001.jpg

/var/www/media_test1/media004/004_pm_001.jpg
                              th004_pm_001.jpg

i basically want to move the pictures from each folder that do not have th into another directory like this:

/var/www/media_test2/media001/001_pm_001.jpg
/var/www/media_test2/media002/002_pm_001.jpg
/var/www/media_test2/media003/003_pm_001.jpg
/var/www/media_test2/media004/004_pm_001.jpg

what i am thinking is to create a list of the images i want to move by using s ls command to list all pictures + their path that don’t have th -> export that to a file -> build a cp command like:

cp /var/www/media_test1/media001/001_pm_001.jpg /var/www/media_test2/media001/001_pm_001.jpg
cp /var/www/media_test1/media002/002_pm_001.jpg /var/www/media_test2/media001/002_pm_002.jpg
...

then execute the command.

the problem is that i don’t know how to write these commands.

Is there a better way of doing this? any ideas on what commands i can use?

thanks

  • 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-02T09:26:59+00:00Added an answer on June 2, 2026 at 9:26 am

    You can use the find command to do that. Make sure the destination directory exists and then run:

    find /var/www/media_test1/media001/ -type f -not -name "th*" -exec cp {} /var/www/media_test2/media001/ \;
    

    That will find all files that don’t begin with “th” and copy them to /var/www/media_test2/media001/.

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

Sidebar

Related Questions

A program we have erred when trying to move files from one directory to
i have a process to move rows from one database to another. Because of
I have a program that needs to move a file from one directory to
I need to move files from one location on the users sdcard to another
Hi I have created a little application to move some files around and put
I have an application and I want to move some of the tables from
I have some code in ASIHTTP, but I want to move on AFNetworking. I
I am trying to copy over some files pulled out from a zip folder,
For some reason, I have to move a lot of C# code from Visual
I have a repository on my PC. Now I want to move some project

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.