linux – Is there an elegant way to move all sub-directories in the current directory to a new sub-directory?

I often run into the following situation. I am in a directory with several sub-directories like so

a b c d

I would like to archive directories a-d by moving them into a new directory at the same level called archive. Ie:


$ls archive
a b c d

The way I currently do this is to make archive and then do a move all. I don’t like this though because you always get the error `mv: cannot move ‘archive’ to a subdirectory of itself, ‘archive/archive’. While this works I don’t like the fact I am ‘abusing’ the built-in exception handling.

$mkdir archive

$mv * archive/
`mv: cannot move 'archive' to a subdirectory of itself, 'archive/archive'

Ideally I would like a solution that does not involve errors. Something along the lines of mv automatically creating the directory but unfortunately that does not work.

$mv * archive/
mv: target 'archive/' is not a directory

system – Searches for files in all subdirectories of a directory

I need to find a file in all subdirectories of the Netflix folder. The file’s name is in this code section of AndroidManifest.xml:

<activity android:name=".ui.launch.UIWebViewActivity" enabled="@bool/phone" theme="@style/Theme.Netflix.Default.FullScreen">                                                                  
  <action android:name="android.intent.action.MAIN"/>                                                                         
  <category android:name="android.intent.category.LAUNCHER"/>                                                             

As you can see in the first line of this section of code, it references the file .ui.launch.UIWebViewActivity I need to find this file. I already ran find -name .ui.launch.UIWebViewActivity but this file is not in the root folder, it can be in any subdirectory right?


I’m following a tutorial, learning to put a payload in an apk manually, but it comes to a stage where it searches the file AndroidManifest.xml for a reference to the code:
<action android: name = "android.intent.action.MAIN" /> <category android: name = "android.intent.category.LAUNCHER" />
And then we have to look for the <activity> tag and then we search for this tag that contains the code snippet above, and then we will find the file that we need to modify, in my case this is .ui.launch.UIWebViewActivity but in the tutorial is this com.dev47apps.droidcam.DroidCam, but when I modify it I cannot find the file, tutorial I’m following:

createdirectory – Creating Multiple Subdirectories in Multiple Directories

Putting files into the wrong directory and then failing to remember where I put them is the bane of my existence. Consequently, I’d like to create a function that can create multiple file directories at once to keep things organized, or at least give the appearance of organization.

Assuming I have already created a number of directories say (all relative, of course):

dnames = {"SubD1", "SubD2", "SubD3"}



I can then refer to each directory giving n, in this case the values 1, 2, and 3

I wish then to create several subidrectories at once for each of these in order, say

{“SubDSub1”, “SubDSub2”,”SubDSub3”}

Hence I set


and create my function (all in a single cell):

makeSubdirectory(x_) := SetDirectory(dnames((n))); 

Which I then map to apply to each of the dnames

makeSubdirectory(n) /@ dnames

Unfortunately, this doesn’t work, but I’m not sure why. Since n is global, I believe it’s incremented, but I can only create the subdirectories in the first directory only, or so it seems. Since the value of x_ is not referred to there seems no reason to create a Module on this multiline function (perhaps not properly interpreted as a single line?) (I’m running V12.1.0.0 on a 64bit Windows system)

Can anyone explain how to create multiple subdirectories mapped across multiple directories?

Sadly, old procedural paradigms die hard for old programmers. I suspect there must be a better more “functional” equivalent here.

How to use the command “rename” on subdirectories as well

There is an answer that is very useful to me in this thread about renaming folders with trailing whitespaces:
Remove Leading or Trailing Space(s) in File or Folder Names

What I can’t figure out how I can change the following command so that it also changes the names in subfolders.

rename -n ‘s/ *$//’ *

I obviously already tried to check this myself with “rename -h” but I can;t see the solution.

Can someone help me with this?

Thanks a lot in advance,


linux – search and rename and mv all files from subdirectories

i have a lot of file inside subdirerctories of txt files with the same name

     ├── cases__in_africa
        │   ├── 2020/10/01.txt
        │   ├── 2020/10/02.txt
        │   ├── 2020/10/03.txt
        │   └── 2020/10/04.txt
        ├── death_in_africa
        │   ├── 2020/10/01.txt
        │   ├── 2020/10/02.txt
        │   ├── 2020/10/03.txt
        │   └── 2020/10/04.txt
2926 directories, 21646 files

i want to search for all files inside a lot of subdirerctories and than rename them to other unique name to move them to other directorie
this my code but the duplicate files not showing

find . -name "*.txt" -exec cp  "{}" ./all ;

python – Strictly only importing modules in subdirectories: is this a good rule?

I’m making my 1st official project. It’s written in Python, is open-sources, and I’d like people to be able to freely and easily fork and modify the code. The project name is “shelf” and the main script/executable is

I’m trying to make everything modular. The main script should be the only thing the end-user manually interact with.

My file structure and import hierarchy:
├── src
│   ├── config
│   │   └──
│   ├── data
│   │   └──
│   ├── downloading
│   │   └──
│   ├── system
│   │   ├──
│   │   ├── rw
│   │   │   ├──
│   │   │   └──
│   │   └──
│   └── ui
│       ├──
│       ├──
│       └── events
│           └──
└── tests

Here, is in the root of the directory.


import src.config.configure as configure
import as database
import as download
import src.system.fileio as fileio
import src.system.reader as reader
import src.ui.cli as cli
import as events

# ...


# ...

The rule I’ve made is that a script can only ever import scripts (modules) in a subdirectory. may not import, and vice-versa. Coupling of these modules is all done in the parent module, which is for and

This rule is made to avoid circular dependencies and modularize all the functions as much as possible. Most functions will be pure functions.

Is this rule of “import only modules in a subdirectory” viable for development?

windows dir /s doesn’t return all subdirectories

I was expecting dir build /S /b /A:D to find all folders in all sub-folder of the current folder that are called build. However not so.

C:GoogleDrive>dir build /S /B /A:D

C:GoogleDrive>dir *build /S /B /A:D


How could I find all such folders?
(I want to delete them so that they don’t waste space and network sending to Google Drive.)