0

how can I move files and folders from a folder to another directory? I am using mv and my files is in a subfolder. do I have to use ../ to specify the path?

I use cd / to go to the root. my folder is in root(after cd /) > backup > folderwithfiles, and I want to transfer it to root > live > newfolder.

how can I achieve this using mv? I tried mv -v ~/Downloads/* ~/Videos/ but I know it will not work since the syntax is for same level folders.

1 Answer 1

1

If your files are currently in /backup/folderwithfiles and you want to move folderwithfiles to /live/newfolder then:

   cd /backup
   mv folderwithfiles /live/newfolder

If newfolder already existed, your files will then be in:

   /live/newfolder/folderwithfiles

If newfolder did not already exist, then your files would be in:

   /live/newfolder

If you just want to move the files that are in folderwithfiles but not move the entire directory, then:

   mv folderwithfiles/* /live/newfolder

In which case newfolder must already exist.

The example mv you posted should have moved the files from the Downloads directory into the Video directory, but not move the Downloads directory itself.

1
  • thanks for this one!
    – eggplants
    Aug 17, 2021 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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