14

I'm new to linux, especially for ubuntu server and it's terminal.... I have such file structure:

-im
 |
 |-t1
   |-1.jpg
 |-t2
   |-2.jpg 
 |-second
   |-t1
     |-3.jpg
   |-t2
     |-4.jpg 

How can i move from second files to main folder, so that t1 contain 1,3.jpg and t2 contain 2,4.jpg...? so that nothing in t1 and t2 to delete, but second subfolder is moved here....

Will be all ok with mv command?

brabertaser19
  • 318
  • 3
  • 4
  • 12

1 Answers1

27

Yes, you will be OK with mv, eg:

mv /path_to_source_folder/filename /path_to_destination_folder/

or, for example from the level of im/second: (cd im/second)

mv t1/3.jpg ../t1/ && mv t2/4.jpg ../t2/

There are more ways to do that, do man find for example, man rsync

when you look at ls command output, the .. (2 dots) 'means one step back', . (one dot) means 'in here' and you can use it as such

Of course if you want to remove the second folder, you use rmdir command or rm -R (use with care, always do man {command} if you are not sure.

catalesia
  • 627
  • 6
  • 11
  • Of course if you want to remove the second folder - will mv leave first copy? O_o – brabertaser19 Mar 02 '13 at 17:12
  • 1
    mv command moves the file, so there will not be any copy, rmdir will not remove the 'second' directory as there are subdirectories. rm -r will or rmdir -p. The best way to learn is to make a copy of the structure and just use the commands and see what happens ;) See what is the difference between rm and rmdir! – catalesia Mar 02 '13 at 17:16
  • with rm and rmdir i something now.... just where wondered, becouse i didn't understand you – brabertaser19 Mar 02 '13 at 17:19
  • 2
    command `rm -r {path_to_folder}` removes the folder and it's subdirectories and files. `rmdir` removes only folders so it's the best way to remove folders if you wanted to be sure they are empty. – catalesia Mar 02 '13 at 17:25