I'm a newbie with some basic skills.
I get a .zip file which contains multiple directories with .csv files within. The program compiling those files does not distinguish between upper and lower case, so you can get files FILE.csv and file.csv in the same directory as separate files.
When I unzip, they are obviously recognized as duplicates.
My PowerShell script as follows works fine if there are no duplicates.
Add-Type -AssemblyName "System.IO.Compression.FileSystem"
function Unzip {
Param(
[string]$zipfile,
[string]$outpath
)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
$sourcefile3 = Get-ChildItem 'root\Drop\Archive*.zip'
$destination3 = 'root\Drop\All_Files'
Unzip $sourcefile3 $destination3
However, because my .zip contains multiple directories, I cannot specify a file name in the $destination3. I tried this, but it created a new folder instead of renaming that duplicate file within a folder.
if (Test-Path $destination3) {
$i = 0
while (Test-Path $destination3) {
$i += 1
$destination3 = ''root\Drop\All_Files$i'
}
}
I read here and here, but this talks about files, not files within directories/folders.