How can I move all files except one? I am looking for something like:
'mv ~/Linux/Old/!Tux.png ~/Linux/New/'
where I move old stuff to new stuff -folder except Tux.png
. !-sign represents a negation. Is there some tool for the job?
Click the first file or folder you want to select. Hold down the Shift key, select the last file or folder, and then let go of the Shift key. Hold down the Ctrl key and click any other file(s) or folder(s) you would like to add to those already selected.
Using mv Command The mv command is used to move files and directories from one place to another. We can also use it to rename files and directories. This will move all the files from /path/subfolder to /path/ except for hidden files and directories.
Windows PC: Left-click the first item, then hold down the Ctrl key while you left-click on each additional file. Let go of the Ctrl key, and you can left-click anywhere on one of the blue selected files to drag it to another location or right-click anywhere in the list to cut or copy.
If you use bash and have the extglob
shell option set (which is usually the case):
mv ~/Linux/Old/!(Tux.png) ~/Linux/New/
Put the following to your .bashrc
shopt -s extglob
It extends regexes. You can then move all files except one by
mv !(fileOne) ~/path/newFolder
Note that, in copying directories, the forward-flash cannot be used in the name as noticed in the thread Why extglob except breaking except condition?:
cp -r !(Backups.backupdb) /home/masi/Documents/
so Backups.backupdb/
is wrong here before the negation and I would not use it neither in moving directories because of the risk of using wrongly then globs with other commands and possible other exceptions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With