How to backup all Photos and PDF on a windows machine

I am preparing to move from Linux to Windows on my main PC. I did some research online and had trouble finding an exact VBS script to find all photos with an extension of jpg and all pdfs on my hardrive.

Even though i am not really a VBS guy I compiled the following script that will rifle through your entire CDrive and move all photos into a common directory. I created this backup in preparation of taking my main home pc to Ubuntu Linux and needed a full backup of all my images and pdfs. Like most people my folder structure on windows is fairly disorganized and I just throw photos everywhere. The only downside to this script is you literally get everything. So I had a little cleanup to do removing photos that were brought in from videogames. You can change line 6 (CopyFiles fso.GetFolder(“C:\”)) to the folder you desire and it will scan from that folder down. If you do not have access to a folder or file it will skip the file/folder. Once all the photos a copied into your destination folder be sure to move them to an external location. I use Google drive as my backup repository. I found this script useful so I posted it here.



Set fso = CreateObject("Scripting.FileSystemObject")

testfolder = “.\backups”

CopyFiles fso.GetFolder(“C:\”)
Sub CopyFiles(fldr)
on Error Resume Next
Set fc = fldr.Files
For Each f In fc
basename = fso.GetBaseName(f)
extension = fso.GetExtensionName(f)
If ((LCase(extension) = “jpg” ) OR ( LCase(extension) = “pdf” )) Then
dest = fso.BuildPath(testfolder, f.Name)
count = 0
Do While fso.FileExists(dest)
count = count + 1
dest = fso.BuildPath(testfolder, basename & “_” & count & “.” _
& extension)
f.Copy dest
End If
For Each sf In fldr.SubFolders
CopyFiles sf
End Sub

function isValid(strDir)
isValid = true
for each strInvalidProfile in arrInvalidProfiles
if (objDir.Name = strInvalidProfile) then isValid = false
end function

Leave a comment

Your email address will not be published. Required fields are marked *

7 − = four