Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have folder "F A" containing some subfolders and files and another folder "F B" containing the same folder structure but no file:

find . -type d
./F A
./F A/SF A
./F A/SF B
./F A/SF C
./F B
./F B/SF A
./F B/SF B
./F B/SF C

How can I write a mv command to move any file under "F A" to its equivalent folder in "F B"?

find . -type f -exec mv {} "./F B" \; 

will just mv any file under "F A" to "F B", but not in its correct subfolder.

share|improve this question

migrated from Dec 29 '12 at 9:31

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

You need to specify the relative path twice:

find ./FolderA -type f -exec mv "{}" "./FolderB/{}" \; 
share|improve this answer

You must log in to answer this question.