linux – How to delete all files except some specific file (for many folders in a directory)? via bash script

So I have a Master folder that contains about 800 sub-folders (eg. 1,2,3…) which contains many files but I want to delete everything else except the file that ends with *tsv.
Is there a way to do this via a bash script?

Master Folder

Folder #1

  • sample.txt
  • sample2.txt
  • test.tsv
  • sample.tsv

Folder #2

  • sample.txt
  • sample2.txt
  • test.tsv
  • sample.tsv

and so on..

Thank you in advance.

python – Generate many, many folders fast

I’ve made a program which makes the folders a-z, and in each of those makes the folders a-z, and in each of… you get it. many, many folders. its quite slow at the moment, would there be any way to optimize?

import os
from os import chdir,mkdir,rmdir
from os.path import isdir
from sys import exit

if == "nt":


CHAR_GREEN = "u001b(32m"
CHAR_RESET = "u001b(0m"
CHAR_WHITE = "u001b(37m"
CHAR_CYAN = "u001b(36m"
CHAR_MAGENTA = "u001b(35;1m"
CHAR_YELLOW = "u001b(33m"

PREFIX = "dir_"
CHARS_ALPHABET = ("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", " ") #last character is empty whitespace

colors_dict = {
    0: CHAR_RESET,
    1: CHAR_GREEN,
    4: CHAR_CYAN,

def make_recursive():
    usr = int(input("Input how many directores you want:n> "))
    print(f"Making '{usr}' directories with prefix '{PREFIX}'n")
    for curGoal in range(usr):
        curGoal += 1
            print(f"Made directory '{PREFIX}{curGoal}', navigated")
        except (FileNotFoundError, OSError):
            input(f"I can't go any further, MAX_PATH is still limited at 260 characters for this system. Please remove this limit, and run me again!nnPress the enter key to exit...")
        except FileExistsError:
            print(f"Already found directory '{PREFIX}{curGoal}', navigated")

    input("nDone!nnPress enter to exit...")

def rmtree(path : str, level : int = 0):
        start = autotab(level)

        if start != None:
            print(f"{start}Working on level {level}{CHAR_RESET}tttt'{path}'")

    except OSError:
        for folder in os.listdir(path):
                rmtree(f"{path}/{folder}", level+1)
            except NotADirectoryError:
    if os.path.exists(path):
def make_letters():
    for char in CHARS_ALPHABET:

def start_makealphabet():
    except FileExistsError:
        input("Alphabet already exists!nnPress the enter key to delete it...")


        input("nAlphabet deleted!nnPress the enter key to exit...")


    input(f"nnnn{CHAR_MAGENTA}Generation done!nn{CHAR_RESET}Press the enter key to exit...")

def autotab(level):
    if level == 0 or level > LOGLIMIT:
        return None
        returnString = colors_dict(level)
    except KeyError:
        returnString = ""
    while level != 1:
        level -= 1
        returnString += "t"
    return returnString

def make_alphabet(level=1, curpath=""):
    for char in CHARS_ALPHABET:
        start = autotab(level)
        if start != None:
            print(f"{start}Working on level {level}{char}{CHAR_RESET}")
        if level < DIRLIMIT:
            make_alphabet(level+1, f"{curpath}{char}")
            with open(f"{curpath}{char}", "w"):

if __name__ == "__main__":
    except KeyboardInterrupt:
        input("Program stopped.nnPress the enter key to exit...")

Means to view offline gmail backups with folders preserved and without a mail client

I was able to make an mbox backup of a personal gmail account as per here:

I used a program called mbox viewer which successfully imported the emails, but combined them all to one folder as shown below.

enter image description here

Is there a way to have the tag / folder information be recognized as separate folders in a gmail backup?

html – css,js,img folders not available for subdomain pointing to subfolder

I referenced all assets in the html with ../img/, ../css/, ../js/ paths.

These are client-side URL-paths; not server-side filesystem-paths. If the browser is currently at then a URL such as ../img/myimage.jpg cannot be resolved as intended from a client-side request. Since the browser cannot “go up” another directory (or rather URL path-segment) level – since it is already at the document root – it will most probably be resolved as – which presumably fails (404).

The same as typing directly in the browser. The ../ path segment needs to be resolved by the browser before the request can be made.

You are probably better off not using relative URL-paths during development (unless you have specific requirements). Use a root-relative URL-path (starting with a slash) or absolute URL (with scheme + hostname) instead.

You need to rethink your directory structure. What exactly are you trying to achieve? A common repository for all assets or a way to reference assets on the main domain, without explicitly specifying an absolute URL.

There are various workarounds:

  • Use absolute URL-paths to your main domain. eg.

  • Point the subdomain at the same root directory as your main domain and use a root-relative URL-path. eg.

  • Point the subdomain at the same root directory as the main domain and use mod_rewrite to internally rewrite requests for pages to the subdirectory (so the subdirectory is hidden from the URL). But all (or some?) static assets to be served from the parent directory (and are not rewritten)? Reference assets using a root-relative URL-path, relative to the main domain. (Or specify a prefix and make the rewrite conditional?)

  • etc.

windows 10 – How do I setup access to shared folders using certificates?

I have a simple home network with several computers.
While connected to the home network I want my work laptop to have access to shares in other computers, but I don’t want to save my home credentials in the work computer.

How can I setup access using a certificates in a similar way to ssh access with authorized_keys?
I.e. generate a certificate in the work computer and add it to the user account in the home computer.

script – scrap SharePoint folders?

I have an old SharePoint (not SharePoint Online) with multiple parent folders by US States and child folders with different Years. Each year has folders by Orders. I want to go check in each Order folder if it has a document named ‘Order History’. Is there a way to bring result in an excel file with Year and Order number if it has the required document present?

In short, Instead of going into each order folder manually want a way to automatically pull data in rows like SQL does. Is it possible? Where does SharePoint stores all these documents data in the back end?

untagged – How to get a website with a custom password entry form in index.php to prohibit access to all other files and folders

I have a family history website, call it “”. The primary file, index.php, has some introductory remarks of explanation and an html form into which one puts the website’s password (there’s a single password used by all family members). If one runs “” and inserts the correct password and clicks on the “Submit” button, the php code in the file takes you to the first of several html files — call it “first.html,” which gives one links to further html files. All of these files contain family trees, copies of letters, photos, reminiscences, obituaries, etc., and none of them should be available to non-family-members.

The problem is that if an intruder happens to learn the filename “first.html” and puts “” into his/her browser, the intruder is immediately taken to first.html, skipping the password process altogether. From there, the intruder has access to the entire website.

How can I prevent this from happening?

A technician from GoDaddy, my web host, showed me how to insert a password protector in an .htaccess file. With this change, the website’s first action is, in a sterile dialog box, to request a username and password. But I don’t want to employ a username at all and I want to use my custom form for the password.

Any help would be greatly appreciated.

home screen folders – What do you access the Work Profile files via USB with the PC

I am tried to modify the files on the USB via PC that the computerised workings are appeared as you don’t show the files by something.

The device is always when don’t modify the files when nothing the folders were not shown, but the migrated tankings are seen as you will display the files and folders.

An story is that the things are tanked in the world’s code you here not seen, but the PC is that the code is back on and the mobile will does modify the workers called Work Profile as you have seen as the folder.

Thanks for your support.

sharepoint server – Unique accesses on tree folders structure

I have a structure in a list that looks like below:

List 1

  • SubList in a Folder 1.a
  • SubList in a Folder 1.b
  • SubList in a Folder 1.c
  • SubList in a Folder 1.z

I set unique permissions (using groups) for List 1 and every SubList in a Folder 1.a, 1.b etc as they don’t need to see the other content. Every list and sublist has unique permissions.

I need a way to cut the edit access to all the users at once (for all Folders/sublists) when is the cut-off date, so they don’t edit the lists while we’re closing the books.

I realized that even if i remove their access from List 1, because they have individual unique permissions to edit the sublist, they can still edit the sublists.

Is there a way to lock edit for all sublists in folders for all users at once?

Many thanks!

Are there any files or folders (apart from robots.txt and favicon.ico) which MUST go in the root directory?

I know that

  • Robots Exclusion Protocol
  • favicon.ico

must be placed in the root directory, like this:

  • /robots.txt
  • /favicon.ico

What about:

  • /.well-known/ ?

Must /.well-known/ also be placed in the root directory?

Are there any other files or folders which must be placed in the root directory?