N
N
nathan1117772021-11-04 14:36:27
linux
nathan111777, 2021-11-04 14:36:27

How to move all files to another folder besides folder using terminal?

I have a lot of videos on the subject of filters in the Videos folder.
To clean things up a little, I created a filters folder in the Videos folder where I want to move all the videos on this topic.

So I can't write:
mv /home/user/Videos/* /home/user/Videos/filters

Because then the filters folder, which is in Videos, will be copied to itself.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vindicar, 2021-11-04
@nathan111777

Well, if you need to transfer only files, but do not touch other directories, then you can try
mv /home/user/Videos/*.* /home/user/Videos/filters
. Since files usually have extensions.

X
xotkot, 2021-11-04
@xotkot

$ cd $HOME/Videos
$ mv !(filters) filters

if it doesn’t work, then you need to enable the regular expression expansion is enabled or not, you can look with the command
$ shopt -s extglob
$ shopt
...
extglob        	on
...

A
Alexey Kharchenko, 2021-11-04
@AVX

Everything is easier! No need to create problems where there are none.
With the specified command, everything will be transferred as it should, mv will only swear:

mv: невозможно перенести 'videos' в свой собственный подкаталог, 'videos/videos'

The rest will be moved to the specified videos directory.
Well, in your version, filters. Just created for testing, checked.
For the test, make a separate directory and you can add directory files in it in the same way. Well, check it out. You never know how you have something configured in Ubuntu ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question