Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there a bulk way to move assets from Documents into a project?

in General Posts: 1,277

I want to be able to post zip files that contain all the custom art for my projects.

I generally have all my custom art in my Documents folder--it's very easy to just move them there with the Files app--but it seems like, to get them into the actual project, I have to load them one by one with the asset picker UI while inside that project.

Is there a faster way to get a bunch of assets into a project all at once?

{ BTW, I see that there's a tag called "Import asset pictures", which it would be useful to look up--how do I search the forums by tag? }

Comments

  • dave1707dave1707 Mod
    Posts: 9,415

    @UberGoober I think if you put stuff in the Project folder, then everything goes with the project. Since I don’t post large projects with my own assets, I’m not 100% sure.

  • Posts: 1,277

    @dave1707 project folder? I don't see that...

  • dave1707dave1707 Mod
    Posts: 9,415

    @UberGoober I just tried it. I put a unique sprite in the Project folder. I then zipped the project and saved it in the Files app folder. From there I loaded the project and the unique sprite was in that project and usable.

  • Posts: 1,277

    @dave1707 that sounds fantastic if only I could find this "praw-jex" folder of which you speak...

  • dave1707dave1707 Mod
    Posts: 9,415

    @UberGoober Create a project and put sprite() in setup. Tap between the () and an asset list will show. Scroll to the top and the folder will be there with the project name.

  • edited March 18 Posts: 1,277

    @dave1707 could we be having a miscommunication maybe?

    I'm specifically asking how to move a lot of images all at once into a project folder.

    Am I missing something?

    I think what you're talking about is a one-at-a-time process

  • dave1707dave1707 Mod
    Posts: 9,415

    Depending on where they are you might be able to mass move. If they’re in photos, I think you can mass move them. If they’re in one of the Codea folders, you can write a simple program that can read from the folder and save them in the project folder.

  • Posts: 1,277

    They're in the Codea Documents folder.

    I was hoping there was a UI-based solution, but I think I can google what you're talking about if there isn't.

  • dave1707dave1707 Mod
    Posts: 9,415

    The program should be easy. Just read the assets in Documents and ask if it should be copied to Project. If Yes, copy, if No skip and read the next asset name.

  • Posts: 1,277

    Thanks for the tip! It does sound easy. There's a couple things there I haven't done before, but it seems pretty simple to figure out.

  • dave1707dave1707 Mod
    Posts: 9,415

    @UberGoober Here's something simple. Change the folder name to what you want. Try to copy just a few to start. You might have to exit the code to see them in the project folder, maybe not.

    viewer.mode=STANDARD
    
    function setup()
        folder=asset.builtin.Planet_Cute
        tab=folder.all
        pos=1   
        fill(255)     
        stroke(255)
        strokeWidth(2)
    end
    
    function draw()
        background(0)
        if pos<#tab then
            text(tab[pos].name,WIDTH/2,HEIGHT/2-200)
            sprite(folder..tab[pos].name,WIDTH/2,HEIGHT/2)
            text("Copy",WIDTH/2,HEIGHT-100)
            text("Skip",WIDTH/2,HEIGHT-200)
            text("End",WIDTH/2,HEIGHT-300)
            line(0,HEIGHT-50,WIDTH,HEIGHT-50)
            line(0,HEIGHT-150,WIDTH,HEIGHT-150)
            line(0,HEIGHT-250,WIDTH,HEIGHT-250)
            line(0,HEIGHT-350,WIDTH,HEIGHT-350)
        else
            text("Done",WIDTH/2,HEIGHT/2)
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            if t.y>HEIGHT-150 and t.y<HEIGHT-50 then
                img=readImage(folder..tab[pos].name)
                saveImage(asset..tab[pos].name,img)
                print(tab[pos].name.."  copied")
            elseif t.y>HEIGHT-250 and t.y<HEIGHT-150 then
                print(tab[pos].name.."  skipped")
            else
                pos=#tab
            end
            if pos<#tab then
                pos=pos+1
            end
        end 
    end  
    
  • Posts: 1,277

    Thank you!

  • Posts: 171

    This is very useful to me also thank you!

  • dave1707dave1707 Mod
    Posts: 9,415

    Here’s an updated version. This only looks at png files so if you use the Documents folder you’ll only see png files and not all the projects. Unfortunately I haven’t found a way to update a Project folder other than the Project folder of this program. One way around that is to copy this code to another project, copy what you want into that Project folder, delete this code in that project and then copy the code of the program you want into that project.

    viewer.mode=STANDARD
    
    function setup()
        folder=asset.builtin.Planet_Cute    -- change folder name
        tab=folder.all
        for z=#tab,1,-1 do
            if tab[z].ext~="png" then   -- only keep png files in the table
                table.remove(tab,z)           
            end
        end
        rectMode(CENTER)
        pos=1  
        stroke(255,0,0) 
        strokeWidth(5)
    end
    
    function draw()
        background(0)
        if pos<=#tab then
            sprite(folder..tab[pos].name,WIDTH/2,HEIGHT/2)
            buttons()
        end
        if pos>#tab then
            fill(255)
            text("Done",WIDTH/2,HEIGHT/2)
        end
    end
    
    function buttons()
        fill(101, 210, 229)
        rect(WIDTH-50,HEIGHT-100,100,50)
        rect(WIDTH-50,HEIGHT-170,100,50)
        rect(WIDTH-50,HEIGHT-240,100,50)
        rect(WIDTH/2,HEIGHT-30,300,50)
        fill(0)
        text("COPY",WIDTH-50,HEIGHT-100)
        text("SKIP",WIDTH-50,HEIGHT-170)
        text("EXIT",WIDTH-50,HEIGHT-240)
        text(tab[pos].name,WIDTH/2,HEIGHT-30)
    end
    
    function touched(t)
        if t.state==BEGAN and pos<=#tab then
            if t.y>HEIGHT-150 and t.y<HEIGHT-50 then
                img=readImage(folder..tab[pos].name)
                saveImage(asset..tab[pos].name,img)
                print(tab[pos].name.."  copied")
                pos=pos+1
            elseif t.y>HEIGHT-220 and t.y<HEIGHT-120 then
                print(tab[pos].name.."  skipped")
                pos=pos+1
            elseif t.y>HEIGHT-290 and t.y<HEIGHT-190 then
                viewer.close()
            end
        end 
    end  
    
  • dave1707dave1707 Mod
    Posts: 9,415

    Another way I was able to update the Project folder of some other project was to create a new tab named Zzz in whatever project you wanted updated. Then put this code into that tab. Since Zzz should be the last thing loaded, then all the functions in my code should override any other same named functions. So when it’s run, my code should run and allow you to update the Project folder. When done, delete the tab Zzz and the Project folder should have what you copied into it.

Sign In or Register to comment.