Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Dec 29 '12 at 9:31

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

1 Answer 1

up vote 1 down vote accepted

You need to specify the relative path twice:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.