20/12/2022
Mamy wielki folder ze zdjęciami i chcieli byśmy go posortować tak aby zdjęcia były w podfolderach ROK/MIESIĄC?
Wystarczy poprosić ChatGPT o skrypt w powershell do tego 😁
SKRYPT
# Set the source and destination directories
$source = "C:\Source\Folder"
$destination = "C:\Destination\Folder"
# Get all files in the source directory
$files = Get-ChildItem $source
# Loop through each file and move it to the appropriate subfolder
foreach ($file in $files) {
# Get the year and month of the file's creation date
$year = $file.CreationTime.Year
$month = $file.CreationTime.Month
# Construct the path to the destination subfolder
$subfolder = "$destination\$year\$month"
# Create the subfolder if it doesn't already exist
if (!(Test-Path $subfolder)) {
New-Item -ItemType Directory -Path $subfolder
}
# Move the file to the destination subfolder
Move-Item -Path $file.FullName -Destination $subfolder
}