Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
Are you sure you have mentioned the correct files in your question? I feel you meant t1 should contain 1, 3.jpg and t2 should contain 2, 4.jpg, right? –  Jobin Mar 2 '13 at 16:59
    
Good question, that's how I understood it anyway ;) –  catalesia Mar 2 '13 at 17:02
    
@Jobin sorry, yes you right –  brabertaser1992 Mar 2 '13 at 17:03
    
@brabertaser1992: Then, please edit the question to accommodate the correction. –  Jobin Mar 2 '13 at 17:05
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Of course if you want to remove the second folder - will mv leave first copy? O_o –  brabertaser1992 Mar 2 '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 2 '13 at 17:16
    
with rm and rmdir i something now.... just where wondered, becouse i didn't understand you –  brabertaser1992 Mar 2 '13 at 17:19
1  
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 2 '13 at 17:25
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.