Compress files in folder to zip file by using PS
Date : March 29 2020, 07:55 AM
Any of those help You can detect empty directories by testing against an empty return from get-childitem. For example, this will return the list of empty directories dir | where{$_.PSIsContainer -and -not (gci $_)}
Get-ChildItem $files | where{-not ($_.PSIsContainer -and -not (gci $_))} | foreach {$zipfile.CopyHere($_.fullname)}}
|
IF depending on number of files per folder --unix
Date : March 29 2020, 07:55 AM
Any of those help To get the number of lines I would recomend piping ls -l into wc -l, this will spit out the number of lines in your directory as follows... Atlas $ ls -l | wc -l
19
#!/bin/bash
amount=$(ls -l | wc -l)
if [ $amount -le 5 ]; then
echo -n "There aren't that many files, only "
else
echo -n "There are a lot of files, "
fi
echo $amount
Atlas $ ./howManyFiles.sh
There are a lot of files, 19
Atlas $ ./howManyFiles.sh
There aren't that many files, only 3
|
Powershell to move files to folder in increments and compress each folder
Date : March 29 2020, 07:55 AM
will help you A big thank you to //\O// for his out-zip function! This will do what you want: function out-zip {
Param([string]$path)
if (-not $path.EndsWith('.zip')) {$path += '.zip'}
if (-not (test-path $path)) {
set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
}
$ZipFile = (new-object -com shell.application).NameSpace($path)
$input | foreach {$zipfile.CopyHere($_.fullname)}
}
$Path = "C:\Temp"
$FileList = gci $path
[int]$FilesPerZip=100
For($i=1;$i -le [Math]::Ceiling($FileList.count/$FilesPerZip);$i++){
md "c:\$($i)"
gci $path|random -Count $FilesPerZip|%{$_.moveto("c:\$i\$($_.name)")}
}
(1..[Math]::Ceiling($FileList.count/$FilesPerZip))|%{gi "c:\$_"|out-zip "C:\$_.zip"}
|
How to create folder, files in this folder, compress folder (in zip or rar file) and upload this to the desktop with Jav
Date : March 29 2020, 07:55 AM
Hope this helps You can use the JSZip library to do this https://stuk.github.io/jszip/var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
var content = zip.generate({type:"blob"});
saveAs(content, "example.zip");
|
How to compress text files of N number sub folder which contains N number text files?
Date : March 29 2020, 07:55 AM
this will help I have an answer for this problem. But this solution is using a static path, and not a dynamic path. So when this batch file is executed, it produces the output exactly as wanted, but only for a specific app folder according to code below. set loc="C:\Program Files\WinRAR"
cd /D %loc%
rar.exe a -r -agYYYY-MM-DD -df -ep %source%\app1\log_.rar %source%\app1\*.txt
set "source=C:\Program Files\WinRAR"
for /R /D %%s in (.\*) do (
echo %%s
for %%F in (%%s\*.txt*) do (
"%source%\rar.exe" a -r -agYYYY-MM-DD -df -ep %%s\log_.rar %%F
)
)
pause
|