commit 9eadeb4b0a6bbfde8e39dd76de522ccde7bb2499 Author: gribse Date: Thu Oct 10 15:11:32 2024 +0200 1st commit diff --git a/AVP/AVP02/240901AVP01 tes test.txt b/AVP/AVP02/240901AVP01 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP03/240901AVP01 tes test.txt b/AVP/AVP03/240901AVP01 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP04/240901AVP04 tes test.txt b/AVP/AVP04/240901AVP04 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP05/240901AVP05 Untitled.png b/AVP/AVP05/240901AVP05 Untitled.png new file mode 100644 index 0000000..564854c Binary files /dev/null and b/AVP/AVP05/240901AVP05 Untitled.png differ diff --git a/AVP/AVP05/240901AVP05 tes test.txt b/AVP/AVP05/240901AVP05 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP05/Pasted image 20231031073718.png b/AVP/AVP05/Pasted image 20231031073718.png new file mode 100644 index 0000000..13e7553 Binary files /dev/null and b/AVP/AVP05/Pasted image 20231031073718.png differ diff --git a/AVP/AVP06/240901AVP06 Untitled.png b/AVP/AVP06/240901AVP06 Untitled.png new file mode 100644 index 0000000..564854c Binary files /dev/null and b/AVP/AVP06/240901AVP06 Untitled.png differ diff --git a/AVP/AVP06/240901AVP06 tes test.txt b/AVP/AVP06/240901AVP06 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP06/Pasted image 20231031073718.png b/AVP/AVP06/Pasted image 20231031073718.png new file mode 100644 index 0000000..13e7553 Binary files /dev/null and b/AVP/AVP06/Pasted image 20231031073718.png differ diff --git a/AVP/AVP07/240901AVP07 Untitled.png b/AVP/AVP07/240901AVP07 Untitled.png new file mode 100644 index 0000000..564854c Binary files /dev/null and b/AVP/AVP07/240901AVP07 Untitled.png differ diff --git a/AVP/AVP07/240901AVP07 tes test.txt b/AVP/AVP07/240901AVP07 tes test.txt new file mode 100644 index 0000000..e69de29 diff --git a/AVP/AVP07/Pasted image 20231031073718.png b/AVP/AVP07/Pasted image 20231031073718.png new file mode 100644 index 0000000..13e7553 Binary files /dev/null and b/AVP/AVP07/Pasted image 20231031073718.png differ diff --git a/GestionVersionV1.0.ps1 b/GestionVersionV1.0.ps1 new file mode 100644 index 0000000..3cecc80 --- /dev/null +++ b/GestionVersionV1.0.ps1 @@ -0,0 +1,61 @@ + +# Define the source directory +$sourceDirectory = ".\AVP" + + + +# Get all folders starting with "AVP" in the source directory +Write-Host "Getting folders in $sourceDirectory" +$folders = Get-ChildItem -Path $sourceDirectory -Directory | Where-Object { $_.Name -like "AVP*" } + +# If no folders are found, create the first folder +if ($folders.Count -eq 0) { + Write-Host "No folders found. Creating first folder: AVP01" + New-Item -ItemType Directory -Path (Join-Path -Path $sourceDirectory -ChildPath "AVP01") -ErrorAction SilentlyContinue + return +} + +# Find the folder with the largest number after "AVP" +Write-Host "Finding the latest folder" +$latestFolder = $folders | Sort-Object -Property { [int]($_.Name -replace "[^\d]") } | Select-Object -Last 1 + +# Increment the number in the folder name +$latestNumber = [int]($latestFolder.Name -replace "[^\d]") +$newNumber = $latestNumber + 1 +$newFolderName = "AVP" + $newNumber.ToString().PadLeft(2, '0') + +# List to the console the folders found, ask before creating the new one "AVPXX" +Write-Host "`nFolders found:" +$folders | ForEach-Object { Write-Host $_.Name } +Write-Host "`nWould you like to create the nex AVP "$newFolderName" ? Press any key to continue or CTRL+C to exit..." +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + + +# Create the new folder +$newFolderPath = Join-Path -Path $sourceDirectory -ChildPath $newFolderName +Write-Host "Creating new folder: $newFolderName" +New-Item -ItemType Directory -Path $newFolderPath -ErrorAction SilentlyContinue + +# Copy the contents of the latest folder to the new folder +$latestFolderPath = Join-Path -Path $sourceDirectory -ChildPath $latestFolder.Name +$filesToCopy = Get-ChildItem -Path $latestFolderPath -File | Where-Object { $_.Extension -ne ".stl" } + +foreach ($file in $filesToCopy) { + $newFileName = $file.Name -replace "AVP\d{2}", $newFolderName + $newFilePath = Join-Path -Path $newFolderPath -ChildPath $newFileName + Write-Host "Copying file: $($file.Name)" + Copy-Item -Path $file.FullName -Destination $newFilePath +} + +# Pause at the end +$filesCopied = Get-ChildItem -Path $newFolderPath -File +$totalSize = 0 + +foreach ($file in $filesCopied) { + $totalSize += $file.Length +} + +$sizeInMB = [Math]::Round($totalSize / 1MB, 1) + +Write-Host "`nAll files copied for a total of $sizeInMB MB.`nPress any key to exit..." +$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") \ No newline at end of file