Results 1 to 6 of 6

Thread: Move Files to SubFolders

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Regular
    Joined
    Jun 2017
    Posts
    26
    Location
    I'm still spinning my wheels.

    I will try to explain the issue again in detail.

    I have a script that runs
    For Each folderIdx In files

    These files are located in the following directory
    C:\Rendermation\


    At first there is only one file Ill call "Solitaire"

    A subfolder with this name is created programatically
    C:\Rendermation\render\solitaire
    This subfolder is created by using the following code

    For Each folderIdx In files

    If Not folderexists(strFolder & "\renders\" & folderidx.name) Then
    mkdir strFolder & "\renders\" & folderidx.name
    End If


    Next




    The script then opens all files in that initial directory (C:\Rendermation\) and saves them with a prefix.
    bluestone_solitaire
    perspective_solitaire
    side_solitaire
    solitaire (this is my original file)
    throughfinger_solitaire
    topangle_solitaire

    The script then creates images based on that prefix that are saved in a subfolder
    C:\Rendermation\renders

    At the end of this process there are 18 files for each prefix. So if i have one original file (Solitaire) then the result is 108 image files. However if I drop 5 original files then I get 30 prefix files and 540 images.

    So i added code to sort through the files. And I finally got it to work on some of the files.

    This is example of one of the blocks of code for one of the prefixes.

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & ".png") Then

    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & ".png", "C:\Rendermation\Renders\" & folderIdx.name & "\"

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & "_Metal1.png") Then
    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & "_Metal1.png", "C:\Rendermation\Renders\" & folderIdx.name & "\"
    End If

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & "_Metal2.png") Then
    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & "_Metal2.png", "C:\Rendermation\Renders\" & folderIdx.name & "\"
    End If

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & "_CenterGem.png") Then
    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & "_CenterGem.png", "C:\Rendermation\Renders\" & folderIdx.name & "\"
    End If

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & "_SideGem.png") Then
    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & "_SideGem.png", "C:\Rendermation\Renders\" & folderIdx.name & "\"
    End If

    If fileexists(strFolder & "\renders\bluestone_" & folderIdx.name & "_AccentGem.png") Then
    fs.MoveFile "C:\Rendermation\Renders\bluestone_" & folderIdx.name & "_AccentGem.png", "C:\Rendermation\Renders\" & folderIdx.name & "\"
    End If

    End If



    The problem .... this code does not work until the script creates the images for the original file (Solitaire) in the list below. So in theis example when it completes Solitaire, it successfully moves all the files into their respective subfolder
    C:\Rendermation\render\solitaire

    However any prefix files that fall alphabetically after Solitaire never get sorted.


    bluestone_solitaire
    perspective_solitaire
    side_solitaire
    solitaire (this is my original file)
    throughfinger_solitaire doesnt get sorted
    topangle_solitaire doesnt get sorted


    I believe the problem is the folderidx.name doesnt initiate until after creating the images for that file. I have tried so many things to solve this and I am totally lost.

    My approach to do this as one script may be all wrong. I've also tried to separate it into two scripts, one that creates the images and one that sorts the files, but I have not been able to figure out how to create something that sorts the files based on the name of the subfolder within the directory. I'm including a screenshot of the directory in case anyone has ideas.

    Thanks in advance to anyone who has ideas.
    Jill
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •