[ b / kemono / coomer ]

/kemono/ - kemono.party

Kemono Development and Discussion
Name
Email
Subject
Comment
Verification
File
Password (For file deletion.)

File: 1659381947217.jpg (385.66 KB, 1050x742, 4b3ebcae44b11822bea1014d17….jpg)

 No.22830

>7z a -mx9 -md1024m -mfb273 -ms16g -mmt2

Can someone share or please make a script that can point to a directory, look for directories three levels down, and compress a folder to .7z with these settings and then delete the folder when it was successfully archived, and repeat the process until there are no more folders?

You can cut down the size for files like .psd, .psd, etc by about 90% in most cases.

I found this Windows PS script but it only compresses folders where the script is located in and it doesn't delete the folder.
>$7z = "C:\Program Files\7-Zip\7z.exe"
>Get-ChildItem -Path $PSScriptRoot -Directory | ForEach->Object {
> $path = "$(Split-Path $_.FullName >-Parent)\newarchive"
> & "$7z" a -mx9 -md1024m -mfb273 -ms16g -mmt2 $path >"$($_.FullName)\*"
> Move-Item "$path.7z" "$($_.FullName).7z"
>}

 No.22847

I guess, something like [code]
$7z = '7z'
$path = 'C:\ass'
#—
$l1dirs = gci -Path $path -Directory
foreach ($l1dir in $l1dirs) {
$l2dirs = gci -Path $l1dir.FullName -Directory
foreach ($l2dir in $l2dirs) {
$l3dirs = gci -Path $l2dir.FullName -Directory
foreach ($l3dir in $l3dirs) {
$name = $l3dir.FullName
&$7z a blah-blah-blah
if ($LASTEXICODE -eq 0) {
rm $name -Recurse
} else {
echo "FUCKSHIT $LASTEXICODE"
}
}
}
}
[/code]
(Can't promise it works, writing by memory)
Just google the actual 7z command to archive the folder instead of blah-blahs.

 No.22853

>>22847
Thanks for reaching out, bro.

I got this error
>PS C:\1> .\test.ps1
>7-Zip 22.00 (x64) : Copyright (c) 1999-2022 Igor Pavlov : >2022-06-15
>Command Line Error:
>Cannot find archive name
>FUCKSHIT
>PS C:\1>

I did some searching and found this but I've no idea what any of this means because I'm too dumb to make a script, please give it a read and help me
https://stackoverflow.com/questions/12708696/using-7zip-to-extract-rar-files-but-cannot-find-archive

 No.22885

>>22853
7z command is wrong, I don't know, I don't pack archives often, much less through cli.
tldr says it's "7z a path/to/archive.7z path/to/file_or_directory", so I guess, try:
"&$7z a ($name+'.7z') -mx9 -md1024m -mfb273 -ms16g -mmt2 $name"

 No.22886

>>22885
Thank you, it works. However, it's not removing the folder after successfully archiving it.

>7-Zip 22.00 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-06-15

>Scanning the drive:
>1 folder, 1 file, 88423675 bytes (85 MiB)
>Creating archive: C:\Folders\level 1\level 2\level 3\2165691 >[2021-04-25].7z
>Add new data to archive: 1 folder, 1 file, 88423675 bytes >(85 MiB)
>Files read from disk: 1
>Archive size: 22570588 bytes (22 MiB)
>Everything is Ok
>FUCKSHIT

 No.22890

>>22886
$LASTEXICODE should be $LASTEXITCODE

 No.22891

>>22890
Changed it, still not deleting any folder

>7-Zip 22.00 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-06-15

>Scanning the drive:
>1 folder, 2 files, 63791997 bytes (61 MiB)
>Creating archive: C:\1\level 1\level 2\level 3\2531699 >[2021-07-27].7z
>Add new data to archive: 1 folder, 2 files, 63791997 bytes (61 MiB)
>Files read from disk: 2
>Archive size: 16075519 bytes (16 MiB)
>Everything is Ok
>FUCKSHIT 0

 No.22894

-eq should be -neq

 No.22895

>>22894
>ParserError: C:\1\test.ps1:12
>Line |
> 12 | if ($LASTEXICODE -neq 0) {
> | ~~~~
> | Unexpected token '-neq' in expression or statement.

 No.22899

>>22895
I mean -ne

 No.22902

>>22899
Didn't work :(

>7-Zip 22.00 (x64) : Copyright (c) 1999-2022 Igor >Pavlov : 2022-06-15

>Scanning the drive:
>1 folder, 1 file, 57977139 bytes (56 MiB)
>Creating archive: C:\1\level 1\level 2\level 3\2338856 [2021-06-07].7z
>Add new data to archive: 1 folder, 1 file, >57977139 bytes (56 MiB)
>Files read from disk: 1
>Archive size: 6869833 bytes (6709 KiB)
>Everything is Ok

 No.22976

>>22902
More specifically?

 No.22990

>>22976
Same as before, it zips every folder three levels down but won't delete the folder after successfully compressing it.

 No.22996

>>22990
Scrqtch that, it's -eq, check that you fixed $LASTEXITCODE in both places, otherwise just replace that if-else with "rm $name -Recurse -Force".

 No.22999

>>22996
>it's -eq, check that you fixed $LASTEXITCODE in both places
Same error as >>22990
>otherwise just replace that if-else with "rm $name -Recurse -Force".
Same error, I did it like this https://pastebin.com/hNZMjBzf



[Return][Go to top] [Catalog] [Post a Reply]
Delete Post [ ]
[ b / kemono / coomer ]