0

Let's say I have a directory called folder_1. Folder_1 has many directories but they all start with 1. Each of these directories has text files, images, etc. I want to move all the content in each of these directories to the parent folder_1.

My assumption is that I have to use something like:

mv -v /folder_1/*1 /folder_1/

But I get the error message that everything is the same file.

3
  • I'm suggesting an edit for readability, this is hard to wrap my head around in it's current state. Oct 3, 2016 at 18:42
  • From what I can tell, your MV command trying to move everything from 'folder_1' to 'folder_1', not the root. Root is simply '/'. Written out in english, your command appears to say something like "Move the contents of folder 1 that start with a 1 to folder 1", which the interpreter won't do since they're already there. Oct 3, 2016 at 18:46
  • Possible interesting reading: stackoverflow.com/questions/17105150/… (where in your case the pattern is folder1/1*. And you want to exec a mv {} +
    – Hennes
    Oct 3, 2016 at 18:51

1 Answer 1

0

Try:

mv -v /folder_1/1*/* /folder_1

This would move all files/folders from subfolders starting with 1 into the parent. However, this would omit "hidden" files/folder, whose name starts with a dot ..

To move those as well, try:

find /folder_1/1*/ -mindepth 1 -maxdepth 1 -exec mv -v \{\} /folder_1 \;
1
  • The first worked fabulously. Oct 5, 2016 at 0:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .