2

I have a folder and sub folders and massive numbers of files as follows:

Folder  called Movies
Sub Folder called "009 - A bad Wolf"
Files called  " 009  A bad Wolf.avi"
Files  called  " 009  A bad Wolf.txt"
Files  called  " 009 - A bad Wold.nfo"
Sub folder   A damn Good Film
Files          >  A Very good Film .mp4
Files          >  A very good Film .nfo
Files          > A Very good Film.txt
Files          > American Babe -Estelle Feat Kan Wass.mkv
Files          > American Babe -Estelle Feat Kan Wass.nfo
Files          > American Babe -Estelle Feat Kan Wass-poster.jpg
Files          > American.History.X.1998.Bluray.1080p.DTS-HD-7.1.x264-Grym
Sub Folder     > Baste - taste
.
.
Files          > Baa Baa Sheep.ogg
Files          > Baa Baa Sheep.nfo
Files          > Baa Baa Sheep.txt
.
.
Files          > Saa Baa Sheep.mp3
Files          > Saa Baa Sheep.nfo
.
Files          > Zaa Baa Sheep.flv
Files          > Zaa Baa Sheep-poster.jpg
Files          > Zaa Baa Sheep.nfo
Files          > Zaa Baa Sheep.txt

How can I get each similar set of files into individual directories without going through one by one? There are 1075 files and sub folders in the sub folder and 6 file in the main folder + the sub folder I am totally out of my depth. I know I have to use find and exec but how to create the directory with matching names? i.e. It should be like this:

Folder > Movies
Sub Folder > 009 - A bad Wolf with the following files in this sub folder:        
        Files          >  009 - A bad Wolf.avi
        Files          >  009 - A bad Wolf.txt
        Files          >  009 - A bad Wold.nfo
 Sub folder     >  A damn Good Film with all the files of same name in this sub folder
 Sub Folder     > A Very good Film with all these files in this sub folder :            Files          >  A Very good Film .mp4
         Files          >  A very good Film .nfo
         Files          > A Very good Film.txt
Sub Folder     > American Babe -Estelle Feat Kan Wass with all these files of same name in this sub folder:
         Files          > American Babe -Estelle Feat Kan Wass.mkv
         Files          > American Babe -Estelle Feat Kan Wass.nfo
         Files          > American Babe -Estelle Feat Kan Wass-poster.jpg
Sub Folder     > American.History.X.1998.Bluray.1080p.DTS-HD with files of same name in this  sub folder:
          Files         > American.History.X.1998.Bluray.1080p.DTS-HD-7.1.x264-Grym
Sub Folder     > Baste - taste as above with files of same names in this sub folder
.
.
Sub Folder     > Baa Baa Sheep with files of same name in this sub folder:
       Files          > Baa Baa Sheep.ogg
       Files          > Baa Baa Sheep.nfo
       Files          > Baa Baa Sheep.txt
.
Sub Folder     > Saa Baa Sheep with files of same name in this sub folder:
       Files          > Saa Baa Sheep.mp3
       Files          > Saa Baa Sheep.nfo
.
Sub Folder     > Zaa Baa Sheep with files of same name in this sub folder:
       Files          > Zaa Baa Sheep.flv
       Files          > Zaa Baa Sheep-poster.jpg
       Files          > Zaa Baa Sheep.nfo
       Files          > Zaa Baa Sheep.txt
5
  • If the solution I presented works out, please "accept solution" to let anyone know it's now solved for you.
    – ejbytes
    Commented Jun 28, 2016 at 5:48
  • @ejbytes: Thank you for the suggested solution but it will not work as it is a semi manual solution requiring me to go through and manually identify the files. What I need is script that goes through and groups these files together. Most solutions I have seen group based on extensions but I need groupings based on names and the tricky part for me is the creation of the new sub directory based on the name of the grouped files.
    – seanbw
    Commented Jun 29, 2016 at 16:03
  • Are you understanding the term "wildcard" in this sense? For example "I like cats", "cats are pretty", "my cats". The wild card is the asterisk *. You can use it like this, * cats, *cats *, cats *. Manual yes, because you have to design the algorithm. There is no way around that. What you are looking for is "ad-hok", which means unique to your situation, so you will have to put some work into it. Nobody will do your work. We can help you find a path or help you with areas you are struggling in.
    – ejbytes
    Commented Jun 30, 2016 at 0:45
  • I don't mind the work. It is that the number of files and folders are so much that I have never succeeded in using Nautilus to open the folder itself. All my attempts to open taht folder to see the list of files just bring smy pc to a halt. that si why i started loking for a scripted solution. Part of the problem is I cna use find to list files of different extensions but is there a find to "find" same names?
    – seanbw
    Commented Jul 1, 2016 at 20:19
  • 'code' find . ( -name "*.mp4" -o -name ".avi" -o -name ".mkv" ) '/code' finds different extensions but how can "find" aggregate same names? I am yet to come across such a script online
    – seanbw
    Commented Jul 1, 2016 at 20:22

1 Answer 1

1

It's pretty easy to accomplish this task and I use this method all the time.

Navigate to the directory in question. Press SHIFT + Right Click (on a blank section of the folder). Select, "Open command window right here". A terminal session will open in this directory.

While you are in this directory you can make the subfolders you wish now either by using the Windows, new Folder, etc. Or you can use the commands:

Make Directory (make a folder)
>mkdir foldername
Move all file extensions to new subfolder (e.g. all flv files)
>mv *.flv ./foldername

If you wish to move files with similar Titles, use a command in this fashion: The * (asterisk) is a wild character. The quotes keep the string in tact holding the blank spaces; otherwise blanks are skipped.

>mkdir "baa black sheep"
>mv "baa black"*.* ./"baa black sheep"

Above:
mv = move
"baa black"* = starts with "baa black" + * (any string after)
./ = this directory
./foldername = the folder in this directory named foldername

mv "baa black"*.* ./"baa black sheep" = move all files that begin with the string 'ball black' and move it into the directory 'baa black sheep'

enter image description here


enter image description here

The above images should help you understand this concept if it's your fist time working with command line interface.


FYI: It's a good idea to to keep your filenames short and without spaces as well as the directories. I would recommend also looking into "Windows DOS commands" to learn some tricks.

4
  • This solution will take so much time I can't run it. A simple mv -fv * command to move this particular folder took two days to complete. I am afraid to even try this out - actually each time I tried to use Nautilus to open the folder I always end up closing it because it hogs all my memory and slows down the pc so much I have to admit defeat and close it. Only a script will help. Thanks anyway.
    – seanbw
    Commented Jul 1, 2016 at 20:15
  • You don't want to use mv * in your case. mv * means move everything. That's not what you want. Study the solution a little closer, you're not grasping the idea of using wild characters. * = all, * x means this before x, up to x. x * means x and everything after x; speaking in "STRINGS".
    – ejbytes
    Commented Jul 1, 2016 at 22:55
  • If it's a script, or a shell script, then you will have to write that script on your own and specify the parameters and the execution. The style of this simple command is used in shell scripts. You may want to do some reading and do some tutorials if you're not familiar.
    – ejbytes
    Commented Jul 1, 2016 at 23:02
  • That was the original request. Maybe you should re-read the Q?
    – seanbw
    Commented Jul 1, 2016 at 23:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .