Monday, 15 June 2015

file - VBS script to grab all images and add value to duplicates -



file - VBS script to grab all images and add value to duplicates -

i'm looking grab files out of e:\ drive without specifying folder. want script grab files in e: drive. here script have. i've tried multiple ways write it, unsucessful on getting work. here script thats working grabbing folder within of drive. sec 1 1 tried modify work. help appreciated.

set fso = createobject("scripting.filesystemobject") testfolder = ".\allpictures" 'fso.createfolder(testfolder) copyfiles fso.getfolder("c:\users\virix\desktop\mytest") sub copyfiles(fldr) each f in fldr.files basename = fso.getbasename(f) extension = fso.getextensionname(f) if lcase(extension) = "jpg" or lcase(extension) = "jpeg" dest = fso.buildpath(testfolder, f.name) count = 0 while fso.fileexists(dest) count = count + 1 dest = fso.buildpath(testfolder, basename & "_" & count & "." _ & extension) loop f.copy dest end if next each sf in fldr.subfolders copyfiles sf next end sub

here 1 modified, can't work.

set fso = createobject("scripting.filesystemobject") testfolder = ".\allpictures" 'fso.createfolder(testfolder) startcopy fso.getdrive("e:\") sub startcopy(fldr) each f in fldr.files basename = fso.getbasename(f) extension = fso.getextensionname(f) if lcase(extension) = "jpeg" or lcase(extension) = "jpg" dest = fso.buildpath(testfolder, f.name) count = 0 while fso.fileexists(dest) count = count + 1 dest = fso.buildpath(testfolder, basename & "_" & count & "." _ & extension) loop f.copy dest end if next each sf in fldr.subfolders startcopy sf next end sub

try :

set fso = createobject("scripting.filesystemobject") testfolder = ".\allpictures" 'fso.createfolder(testfolder) startcopy fso.getfolder("e:\") sub startcopy(fldr) each subfolder in fldr.subfolders each f in fldr.files basename = fso.getbasename(f) extension = fso.getextensionname(f) if lcase(extension) = "jpeg" or lcase(extension) = "jpg" dest = fso.buildpath(testfolder, f.name) count = 0 while fso.fileexists(dest) count = count + 1 dest = fso.buildpath(testfolder, basename & "_" & count & "." _ & extension) loop f.copy dest end if next startcopy subfolder next each sf in fldr.subfolders startcopy sf next end sub

file vbscript folder

No comments:

Post a Comment