问题标签 [compress-archive]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
64 浏览

multithreading - Using Compress-Archive to compress multiple folders multithreadded with Powershell

Everyday I need create archives of the following

I currently have the script working with creating the zip files one at a time, However I can sometimes have 200+ folders to zip and they are different sizes so I would like to get this working multithreadded.

The code asks for the folder via a Folderbrowser dialog.

If someone could either help with the code or point me in the direction where I can find the information for this, I am a beginner with PowerShell but have done some programming.

If there is any other information needed let me know.

0 投票
1 回答
66 浏览

powershell - 根据文件名中的日期归档文件。Powershell 脚本

我正在尝试制作简单的 powershell 脚本,该脚本每天都会归档文件。每个文件在其名称的开头都有日期,例如:20211220_Something.csv, 20211220_SomethingElse.txt, 20211219_Something.csv, 20211219_SomethingElse.txt等...

我想制作从特定目录收集所有带有扩展名(*.txt、*.csv、*.xslx)的文件的脚本,这些目录是:

\\Main\Files\\Main\Files\SecondaryFiles

并将所有具有上述扩展名的文件归档到例如\\Main\Files\archive\2021\12\20.12.zip

其中 2021、12 和 20.12 是文件名前缀中提供的日期元素。在 20.12.zip 中,所有文件都来自\\Main\Files名为“SecondaryFiles”的目录,其中所有文件都来自\\Main\Files\SecondaryFiles. 归档后,我想删除我刚刚压缩的所有文件。

现在我有这段代码循环遍历目录中的所有文件\Main\并提取日期前缀。我曾尝试使用 [Datetime]::parseexact() 方法,但它不起作用,因为我的循环返回整个路径。有人知道如何解决这个问题吗?

然后我从原始目录中删除项目。

还有一件事值得一提的是,我不能确定文件夹是否只包含今天的文件。因此,当整个星期都有文件时,脚本应该可以正常工作,可以说20211214until 20211220

因此,我再次想像上面那样压缩存档文件,但今天的日期路径将包含从文件名前缀中提取的日期。

0 投票
2 回答
51 浏览

powershell - PowerShell 脚本(foreach 循环问题)

我有一个简短的问题,但是我现在站在墙上太久了,所以我不得不问你......情况是:我有一个特殊的文件类型,在不同的文件夹和子文件夹中。我已经设法找到文件,将它们写入 TXT 文件,还设法拆分路径,以便我可以使用文件夹名称和日期命名 ZIP 文件。但我唯一没有得到的是如何仅将文件夹 1 的特殊文件压缩到 Zip-archiv“folder1-date.zip”中,并将文件夹 2 的文件压缩到 Zip-archiv“folder2-date.zip”中。代码部分如下所示:

问题是,找到扩展名的每个文件都在每个 ZIP-Archiv 中(逻辑,因为它是 foreach 中的 foreach)但我找不到正确的方法......谢谢您的帮助!

0 投票
1 回答
57 浏览

powershell - PowerShell - 双循环可能吗?

我想在特定位置压缩目录。源路径是: \\$Computers\Users\$Names

我想要比每台计算机在每台计算机的源路径中的每个用户目录的副本

我尝试使用foreach如下循环:

这实际上有效,但我不知道如何在循环中添加第二个循环。

如果有人可以向我解释该功能或只是一些建议,请尝试这样做。

感谢您的时间。