Link to home
Start Free TrialLog in
Avatar of tcs224694
tcs224694Flag for India

asked on

very interesting php ,vb stuff for real experts

Hi,

I have several images file in a folder like abc.jpg,def.jpg.(2000 images in total)

What i need is i want those images to be placed under separate folder.

Say abc.jpg in folder1 and then def.jpg in folder2.

Next i need to have 3 copies of same image in each folder.

Say in folder1 we have abc.jpg.

What i want is full_abc.jpg,small_abc.jpg,thumb_abc.jpg now in that folder1.(see abc.jpg is not there-only rename is ok size doesnt need to change)

Atlast i need a excel with 2 columns foldername and image name(image name must be the original name :abc.jpg)

I know this is really a hard one to achieve.But hope u guys can do it using php or excel or VBA

For creating some products i need this.

Any help is appreciated.

Thanks
Avatar of Calvin Brine
Calvin Brine
Flag of Canada image

Give this a try.  I have not filtered any files, so this will copy all file regarless of the extension.  If you need to only do jpg's let me know and I can revise.
HTH
cal

Picture-copy.xls
Looks like there are some hidden system files associate to image's that my code is picking up and creating a folder for.  The attached spreadsheet will now filter down to just JPG files.
HTH
Cal

Picture-copy.xls
Avatar of tcs224694

ASKER

Thanks i will check ti now..
I think u have done the second part of it...Anyhow that i cannot able to select a folder that has a .jpg file.

Can u advice me on the first part...How to create 2000 folders and place 1 file each folder?
The folder selector will not show the actual files within the folder....it's  folder selector.  Just select the folder where the files are stored and press the button.
 
Cal
Yes i did .Nothing Happen...
What are the exetension of the files? Are they all .jpg?
Cal
Yes all files are .jpg only...
That's weird.  I think it may have to do with the FSO.Type being different than my testing is returning.  I've revised the code to work based on the file extension instead.  Give this revised code a try.
HTH
Cal

Dim wb As Workbook, ws As Worksheet
Dim fso As Scripting.FileSystemObject, f As File
Dim Folder As String
Dim counter As Integer
 
Set wb = ActiveWorkbook
Set ws = ActiveSheet
 
Set fso = CreateObject("Scripting.filesystemobject")
 
With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    .Title = "Select JPG Folder"
    .ButtonName = "Select Folder"
    .Show
    If .SelectedItems.Count = 0 Then
        MsgBox "Process Cancelled"
        End
    End If
    Folder = .SelectedItems(1)
End With
counter = 1
For Each f In fso.GetFolder(Folder).Files
        
    If Mid(f.Name, InStr(f.Name, ".") + 1, 50) = "JPG" Then
        On Error Resume Next
        fso.CreateFolder Folder & "\" & "Folder" & counter
        On Error GoTo 0
        
        f.Copy Folder & "\" & "Folder" & counter & "\full_" & f.Name, True
        f.Copy Folder & "\" & "Folder" & counter & "\small_" & f.Name, True
        f.Copy Folder & "\" & "Folder" & counter & "\Thumb_" & f.Name, True
        
        ws.Range("A65535").End(xlUp).Offset(1, 0) = Folder & "\" & "Folder" & counter
        ws.Range("A65535").End(xlUp).Offset(0, 1) = f.Name
        
        counter = counter + 1
    End If
Next f

Open in new window

Sorry i dont know how to run this...I tried copy the code and place in the sheet1 by pressing alt f11 but it shows compile error...
ASKER CERTIFIED SOLUTION
Avatar of Calvin Brine
Calvin Brine
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok thanks...