1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need help with imacros

Discussion in 'General Scripting Chat' started by Ruriko, Aug 14, 2012.

  1. Ruriko

    Ruriko Power Member

    Joined:
    May 4, 2008
    Messages:
    524
    Likes Received:
    12
    Ok what the script does it scans a folder and uploads all the files in that folder. I have a csv containing a lot of folder directory paths and I want it to loop it. This is how the steps should be done:
    1. Scan folder
    2. Upload all files
    3. Go to next folder
    4. Repeat step 1 & 2

    How can I do this?

    Code:
    //imacros-js:showsteps yes
    // mythosmint, test with iMacros
    // get a list of all the files in a directory, and upload them
    
    iimDisplay ("Auto Upload Script");
    
    
    // using as a java string (to use string functions if needed)
    // http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
    var folderPath = new String("C:\\Users\\Susan\\Desktop\\Anime\\ova\\");
    
    
    // open a new java file in the folder path, so we can scan the directory to get the file names
    var file = new java.io.File(folderPath);
    
    //  put the file list into a javascript variable
    var files = file.listFiles();
    
    
    // we probabbly need to filter files by extension...
    
    
    // loop through the file list
    for(var index=0; index < files.length; index++) {
    
       // get the name of the file (also add folder path)   
       var filename = folderPath + files[index].getName();   
       
       //alert("filename=["+filename+"]"); // alert the name   
       
       // set the filename as a variable the iim script can access
       iimSet("filename", filename );
       
       // call our upload script
       iimPlay("imagetwist.iim");   
    }