小编Lau*_*ebs的帖子

将文件夹拆分为具有特定大小的较小文件夹

我正在尝试将一个文件夹划分为最大大小为 8 GB 的文件夹。

起始文件夹:

 Folder 1
  2KB file
  2GB file
  7GB file
 Folder 2
  1GB file
  5.6GB file
 Folder 3
  8GB file
Run Code Online (Sandbox Code Playgroud)

我想把它变成:

  Folder A (~7.6GB)
   Folder 1
     2KB file
     2GB file
   Folder 2
     5.6GB file
 Folder B (8GB)
   Folder 1
     7GB file
   Folder 2
     1GB file
 Folder C (8GB)
   Folder 3
     8GB file
Run Code Online (Sandbox Code Playgroud)

目标是您可以组合文件夹并获取原始文件夹的结构。

使用 powershell 可以实现这样的功能吗?我已经看到了一些使用 bash 和 dirsplit 的解决方案,但我真的很想将其保留在 powershell 中,除非有一些现有软件的简单干净的解决方案。

我忘记补充一点,文件夹可能不仅包含文件,有时还包含文件夹。有没有一种解决方案可以在一定程度上递归地执行此操作?

考虑到我没有经常使用 powershell,感觉好像我错过了一些东西。

windows powershell

5
推荐指数
1
解决办法
2623
查看次数

如何在使用次要版本的功能时编写shebang

例如:

testvar = "test"
print(f"The variable contains \"{testvar}\"")
Run Code Online (Sandbox Code Playgroud)

格式化的字符串文字是在python3.6中引入的

如果我使用#!/usr/bin/env python3,如果安装了旧版本的python,它将抛出语法错误.
如果我使用#!/usr/bin/env python3.6,如果没有安装python3.6,它将无法工作,但是更新的版本是.

如何确保我的程序在特定版本上运行?如果使用python3,我无法检查版本,因为它甚至不会在较低版本上启动.

编辑:

我不是说怎么办好呢,当然你可能只是明确地说:"与python3.6运行这个并起来",但什么是确保该程序只与某个版本跑步的正确方式或更新版本使用时./scriptname.py

python posix shebang python-3.x

5
推荐指数
1
解决办法
166
查看次数

标签 统计

posix ×1

powershell ×1

python ×1

python-3.x ×1

shebang ×1

windows ×1