How do I move all files from one folder to a subfolder except .html file using the command line?

i.maddy

I would like to know how can I move all files from folder-A to folder-A's sub-folder except .html file with a command line.

Suppose I am in dist folder and there are 50 files and 5 folders. Now I would like to move all 50 files and 4 folders to one of the subfolder inside dist folder, without having to write all the files name.

Ravexina

Current directory:

$ ls -F
1   12  15  18  20  23  26  29  31  34  37  4   42  45  48  50  8       b.html  foldera/  folderd/
10  13  16  19  21  24  27  3   32  35  38  40  43  46  49  6   9       c.html  folderb/  foldere/
11  14  17  2   22  25  28  30  33  36  39  41  44  47  5   7   a.html  d.html  folderc/  moveHere/

Temporary enable shell extglob and disable history substitution:

$ shopt -s extglob; set +H

To move everything to a directory named "moveHere" excluding html files:

$ mv !(*.html|moveHere) moveHere/

Current directory after moving files:

$ ls
a.html  b.html  c.html  d.html  moveHere

Check new dir:

$ ls moveHere/
1   12  15  18  20  23  26  29  31  34  37  4   42  45  48  50  8        folderb  foldere
10  13  16  19  21  24  27  3   32  35  38  40  43  46  49  6   9        folderc
11  14  17  2   22  25  28  30  33  36  39  41  44  47  5   7   foldera  folderd

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I move all the files with the same name scattered through the file system into one folder?

From Dev

How to move all files in current folder to subfolder?

From Dev

From the command line, how do I zip specific files and directories into one compressed folder?

From Dev

how to move files from subfolder to parent folder?

From Dev

How do I move all files output from a command?

From Dev

Windows batch command to delete files from a folder except one file

From Dev

How do I replace all files in a folder with one file?

From Dev

How do I move window buttons from left to right using command line or by editing a specific file?

From Dev

How do I move window buttons from left to right using command line or by editing a specific file?

From Dev

How to copy folder structure and all files except one file type

From Dev

Move all files in repository from one directory to another using ssh command line

From Dev

How do I move move to the next workspace using command line?

From Dev

Batch file: Copy all files and folder except one folder

From Dev

How do you move files from one folder to the other?

From Dev

How do I copy all files of one specific type from a folder to another folder in Python

From Dev

How to delete all the folder except one folder and its content using command prompt?

From Dev

How do I overwrite image files (in a folder) with one file with command prompt?

From Dev

Batch command to delete everything (sub folders and files) from a folder except one file

From Dev

How can I sort all the files in a folder by subfolder name, then by name?

From Dev

How to ZIP specific files from a folder using Winzip command line?

From Dev

Delete all files except specified files/folders using command line?

From Dev

Delete all files except specified files/folders using command line?

From Dev

Delete all files in the folder except one extension(say .idf) using batch file

From Dev

How to use the move command on Windows, to move all files inside a folder when using quotation symbol?

From Dev

Using Karma, how do I exclude all files that match a pattern except for those within a specific sub-folder?

From Dev

How do I find the biggest file in a folder and subfolders on the command line?

From Dev

Delete all files and folder except two folders using command prompt

From Dev

How do I only copy files to a remote folder on another server that don't already exist in the folder... from the command line in linux?

From Dev

How to delete all files and directory except one named directory from a specific folder in centos

Related Related

  1. 1

    How do I move all the files with the same name scattered through the file system into one folder?

  2. 2

    How to move all files in current folder to subfolder?

  3. 3

    From the command line, how do I zip specific files and directories into one compressed folder?

  4. 4

    how to move files from subfolder to parent folder?

  5. 5

    How do I move all files output from a command?

  6. 6

    Windows batch command to delete files from a folder except one file

  7. 7

    How do I replace all files in a folder with one file?

  8. 8

    How do I move window buttons from left to right using command line or by editing a specific file?

  9. 9

    How do I move window buttons from left to right using command line or by editing a specific file?

  10. 10

    How to copy folder structure and all files except one file type

  11. 11

    Move all files in repository from one directory to another using ssh command line

  12. 12

    How do I move move to the next workspace using command line?

  13. 13

    Batch file: Copy all files and folder except one folder

  14. 14

    How do you move files from one folder to the other?

  15. 15

    How do I copy all files of one specific type from a folder to another folder in Python

  16. 16

    How to delete all the folder except one folder and its content using command prompt?

  17. 17

    How do I overwrite image files (in a folder) with one file with command prompt?

  18. 18

    Batch command to delete everything (sub folders and files) from a folder except one file

  19. 19

    How can I sort all the files in a folder by subfolder name, then by name?

  20. 20

    How to ZIP specific files from a folder using Winzip command line?

  21. 21

    Delete all files except specified files/folders using command line?

  22. 22

    Delete all files except specified files/folders using command line?

  23. 23

    Delete all files in the folder except one extension(say .idf) using batch file

  24. 24

    How to use the move command on Windows, to move all files inside a folder when using quotation symbol?

  25. 25

    Using Karma, how do I exclude all files that match a pattern except for those within a specific sub-folder?

  26. 26

    How do I find the biggest file in a folder and subfolders on the command line?

  27. 27

    Delete all files and folder except two folders using command prompt

  28. 28

    How do I only copy files to a remote folder on another server that don't already exist in the folder... from the command line in linux?

  29. 29

    How to delete all files and directory except one named directory from a specific folder in centos

HotTag

Archive