Saving all images-SOLVED

toxickeys

New Member
I have pictures scattered in my hard drive. How can I gather all pictures into one area and then save all images to my external drive? Or if I cannot gather into one area, then save all pics with one click from my mouse to an external drive.

thanks
 


Last edited:

Neemobeer

Windows Forum Team
Staff member
Well many of the pictures in the Windows or Program Files directories are going to be related to the operating system and applications. Normally you can't write to these locations without elevated rights which most user applications won't run as unless you specifically tell them too. Even so, a couple lines of Powershell could find and copy all the pictures on your system to another location.
 


toxickeys

New Member
So I cannot make copies to a usb drive? There are roughly 1500 pictures taken over the years and not likely able to do this manually.
 


Neemobeer

Windows Forum Team
Staff member
You can either manually or with Powershell.
 


Neemobeer

Windows Forum Team
Staff member
I just wrote this. It will search your entire user profile for pictures and copy them to E:\Pictures. If you plug a flash drive in and say it shows up as drive D or F or some other letter just change the first line to match. I made it handle duplicate file names by appending the last write time to the end so it won't override the existing file.

Code:
$TargetPath = "E:\Pictures"
$SourcePath = "$($env:USERPROFILE)"

$Pictures = Get-ChildItem -Path $SourcePath -Recurse -Include "*.jpg","*.jpeg","*.bmp","*.gif","*.png"

If(-not(Test-Path $TargetPath))
{
    New-Item -Path $TargetPath -ItemType Directory
}

foreach ($Picture in $Pictures)
{
    $NewPicturePath = $null
    $DestinationDirectory = Get-ChildItem -Path $TargetPath
    $PictureExists = $false

    foreach($CopiedPicture in $DestinationDirectory)
    {
        If($Picture.Name -eq $CopiedPicture.Name)
        {
            $WriteTime = ".$($Picture.LastWriteTime.ToString("yyyy-mm-dd"))"
            $extensionIndex = $Picture.Name.LastIndexOf('.')
            $NewPictureName = $Picture.Name.Insert($extensionIndex,$WriteTime)
            $NewPicturePath = "$TargetPath\$NewPictureName"

            Copy-Item -LiteralPath $Picture.FullName -Destination  $NewPicturePath -Force
            $PictureExists = $true
            break
        }
    }

    If(-not($PictureExists))
    {
        Copy-Item -LiteralPath $Picture.FullName -Destination $TargetPath -Force
    }
}
 


toxickeys

New Member
Very nice of you to do that! Very much appreciated. This will also take pictures in Picassa and Adobe Photoshop and put them onto the external drive is that correct?

I copy and paste the entire script is that correct?
 


toxickeys

New Member
There is a Powershell Core 6.0
Is this the correct version to be downloaded/installed? If not which version do you recommend?
 


Neemobeer

Windows Forum Team
Staff member
Powershell is pre-installed on every Windows computer. If you need to edit the copy to location just copy the script into a text file and edit it. You can then copy the code and paste it into a Powerhell console window and hit enter. You can open a Powershell console by clicking on the start button and type powershell.
 


toxickeys

New Member
Powershell is pre-installed on every Windows computer. If you need to edit the copy to location just copy the script into a text file and edit it. You can then copy the code and paste it into a Powerhell console window and hit enter. You can open a Powershell console by clicking on the start button and type powershell.
Here are my options:
Powershell
Powershell (x86)
Powershell ISE
Powershell ISE (x86)
Powershell Modules

Which option should I use with Windows 7 Home Edition running 64 bit?

Thank you.
 


Neemobeer

Windows Forum Team
Staff member
You can use any of them minus Modules. ISE is just a text editor/powershell execution environment mostly used to write scripts.
 


toxickeys

New Member
I now have pictures on my external drive. One last question though. Can I be assured that all pictures from whatever program, be it Adobe Photoshop, Kodak, and in various other places have been copied and sent to the external drive with the script given above? I don't see a way to manually verify that due to the amount of pictures. Hopefully it is but in that case I want to thank you Neemobeer for taking the time to write the script for me. There is no way I could have done that and honestly was not expecting anyone to do that.

Thank you again and all the best in safety and health this coming year.
 


Neemobeer

Windows Forum Team
Staff member
Can I say with 100 % that it grabbed all the pictures no, but most programs only save user data in your profile so it's probably a high % that is got everything. If however you had projects in these applications they likely have their own extensions that you would need to include in the filter in the third line of code. If all you care about is the pictures then you probably have them all.
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top