Welcome › Forums › General PowerShell Q&A › Divide photos into folders
- This topic has 11 replies, 4 voices, and was last updated 1 month, 4 weeks ago by
Participant.
-
AuthorPosts
-
-
November 25, 2020 at 12:59 pm #274110
Hi everyone, I have a folder with a lot of photos. I would like to be able to divide them into subfolders that have as their name the date of acquisition of the photos. Is it possible to have a powershell?
Thanks.
-
November 25, 2020 at 1:50 pm #274128
Absolutely possible. Here’s where I would start. Do Get-Help on the following:
Get-Item
Get-ChildItem
Get-ItemProperty
Copy-Item
New-Item
Come back with some code and maybe I can help you out.
-
This reply was modified 2 months ago by
Mike R..
-
This reply was modified 2 months ago by
-
November 25, 2020 at 2:47 pm #274143
date of acquisition
Hi, I have this:
gci | ? {-not $_.psiscontainer} | % {$_.creationtime.tostring(‘yyyy-MM-dd’)} | sort -unique | % {new-item -type directory $_}
$files = gci | ? {-not $_.psiscontainer}
$folders = gci | ? {$_.psiscontainer}
foreach ($file in $files) {foreach($folder in $folders) {if($file.creationtime.tostring(‘yyyy-MM-dd’) -eq $folder) {move-item $file.fullname -destination $folder}}}
It work fine, but it doesn’t use the date of acquisition
-
November 25, 2020 at 3:31 pm #274149
What is the “date of aquisition”? File objects have the following date properties:
Name
—-
CreationTime
CreationTimeUtc
LastAccessTime
LastAccessTimeUtc
LastWriteTime
LastWriteTimeUtcIs it one of these?
-
November 25, 2020 at 3:43 pm #274155
What is the “date of aquisition”? File objects have the following date properties:
Name
—-
CreationTime
CreationTimeUtc
LastAccessTime
LastAccessTimeUtc
LastWriteTime
LastWriteTimeUtc
Is it one of these?
In windows 10 (Italian) I can sort the files by date, creation date and acquisition date. Only the date of acquisition shows the true date the photos were taken.
-
November 25, 2020 at 3:44 pm #274158
Date the picture was taken is metadata:
-
November 25, 2020 at 3:47 pm #274161
Date the picture was taken is metadata:
<iframe width=”600″ height=”338″ style=”position: absolute; clip: rect(1px, 1px, 1px, 1px);” class=”wp-embedded-content” sandbox=”allow-scripts” security=”restricted” title=”“Use PowerShell to Find Metadata from Photograph Files” — Scripting Blog” src=”https://devblogs.microsoft.com/scripting/use-powershell-to-find-metadata-from-photograph-files/embed/#?secret=puQCzcL6sq” data-secret=”puQCzcL6sq” frameborder=”0″ marginwidth=”0″ marginheight=”0″ scrolling=”no” data-mce-fragment=”1″></iframe>
Hi, could you modify my powershell to make it work? I am just starting out!
-
This reply was modified 2 months ago by
Mauco8045.
-
This reply was modified 2 months ago by
-
November 25, 2020 at 4:30 pm #274179
Date the picture was taken is metadata:
<iframe width=”600″ height=”338″ style=”position: absolute; clip: rect(1px, 1px, 1px, 1px);” class=”wp-embedded-content” sandbox=”allow-scripts” security=”restricted” title=”“Use PowerShell to Find Metadata from Photograph Files” — Scripting Blog” src=”https://devblogs.microsoft.com/scripting/use-powershell-to-find-metadata-from-photograph-files/embed/#?secret=puQCzcL6sq” data-secret=”puQCzcL6sq” frameborder=”0″ marginwidth=”0″ marginheight=”0″ scrolling=”no” data-mce-fragment=”1″></iframe>
In the folders I have .jpg and .raw files. From the .raw files I don’t think you can find the date from the metadata.
-
November 25, 2020 at 4:58 pm #274185PowerShell1234567891011$folder = \\path\to\photosGet-ChildItem -Path $folder -Filter *.jpg | ForEach-Object {# Get date in custom format$dir = get-date -Date ($_.CreationTime) -Format 'yyyy-MM-dd'$dest = Join-Path -Path $folder -ChildPath $dir# Create folder based on custom format and move .jpg,.cr2 filesIF (!(Test-Path -Path $dest)) {New-Item -ItemType Directory -Path $dest -ErrorAction SilentlyContinue}Move-Item -Path $_.FullName,($_.FullName -replace '\.jpg$','.cr2') -Destination $dest}
-
This reply was modified 1 month, 4 weeks ago by
random commandline.
-
This reply was modified 1 month, 4 weeks ago by
random commandline.
-
This reply was modified 1 month, 4 weeks ago by
-
November 26, 2020 at 2:52 pm #274425
Hi, thank you. As I said, for each photo I have 2 files… namephoto.jpg and namephoto.cr2. Is it possible to move all this files?
-
November 27, 2020 at 9:48 am #274605
My edit should work for both file formats
-
November 28, 2020 at 5:40 am #274764
$folder = \\path\to\photos
Hi, thanks for the script. I wanted to ask you if I have to add the folder where it finds the files or if it is enough to put the script in the working folder.
Thank you
-
-
AuthorPosts
- You must be logged in to reply to this topic.