Easiest way to move contents of all subfolders into parent folder

Discussion in 'Other Operating Systems' started by shredder, Oct 23, 2018.

  1. shredder

    shredder Member

    Joined:
    Dec 26, 2001
    Messages:
    10,385
    Location:
    Dec 27, 1991
    Ubuntu 18. Everyday home usage.

    A simple little process. How can you best automate it?

    1. A script (nice)? Could do this easily in DOS 25 years ago, with a bat. Help me create the linux version.

    2. A GUI extension (nicer)? Could do this easily in Windows 10 or 20 years ago (as in, somebody else had created the right-click GUI extension, and you could easily obtain and install it). Can we add this to Ubuntu?

    EXAMPLE OF PROCESS:

    Before:
    Code:
    PARENT_FOLDER/SUB1/file1.txt
                      /file2.wtf
                      /otherthing.docxxx
    PARENT_FOLDER/THING/spreadsheetoftheuniverse.xls
                       /whatever.txt
    PARENT_FOLDER/XTREEGOLD/xtg.bat
                           /yolo.txt
    ...etc...
    
    After:
    Code:
    PARENT_FOLDER/file1.txt
                 /file2.wtf
                 /otherthing.docxxx
                 /spreadsheetoftheuniverse.xls
                 /whatever.txt
                 /xtg.bat
                 /yolo.txt
    ...etc... 
    I could Google this and figure it out myself, but thought it might be a bit of fun (and educational) for the experts here to discuss the best alternatives for solving a simple file process in modern Linux.
     
    Last edited: Oct 23, 2018
  2. BAK

    BAK Member

    Joined:
    Jan 7, 2005
    Messages:
    800
    Location:
    MornPen, VIC
  3. OP
    OP
    shredder

    shredder Member

    Joined:
    Dec 26, 2001
    Messages:
    10,385
    Location:
    Dec 27, 1991
    Thanks for your input BAK. Your 2009 link is a good starting point.

    I don't want to have to type that long technical sentence every time. Let's make it so I only have to jump to terminal in a given folder, and run a three letter command (let's call it "stp", short for "subfolders to parent") to execute the process.

    I also encourage further discussion of the other questions in my post, and other alternatives, in the vein of the principle stated:
    For example, once we have the 3 letter script sorted, we can move on to the GUI implementation.
     
    Last edited: Oct 23, 2018
  4. BAK

    BAK Member

    Joined:
    Jan 7, 2005
    Messages:
    800
    Location:
    MornPen, VIC
    Have a look at "alias", it should achieve this for you. You can use it to create aliases for commands. You could also create a script that runs that command, and name it "stp" and place it in a folder that your shell interprets as containing binaries, such that when you type "stp" it runs that script.
     

Share This Page