Select every nth file from a folder

Hello:
I have a file on my computer that has about 2200 word documents and I need to select every 10th file and place it into another folder. I have zero expierence with this stuff, especially since my imac is my first mac ever; I have had it for about 2 months. Any help would be greatly appreciated !
Thanks

This script
set sourceFolder to choose folder with prompt "Select Source Folder"
set destinationFolder to choose folder with prompt "Select Destination Folder"
set diag to display dialog "Set skip count" default answer "10"
set skipCount to (text returned of diag) as integer
tell application "Finder"
          set theFiles to the files of sourceFolder
          repeat with n from skipCount to (count of theFiles) by skipCount
  duplicate item n of theFiles to folder the destinationFolder
          end repeat
end tell
will prompt you for the source and destination folders (the destination folder must exist already) and then prompt for the number of files to skip.
It will duplicate the selected files from the source to the destination. If you do not want the files to remain in the source folder replace duplicate with move in the script.
To make the above into a script select all the text in the box then right (control) click the selection, select Services->Make New AppleScript.
As with all script gotten from the web make sure you test it out on some dummy files first and make sure you have backups of the data you are working on.
regards
Note this will start with the file at skipCount and increment from there. That is with the skipCount set to 10 the first file moved is file number 10 then 20, 30, etc.
Message was edited by: Frank Caggiano

Similar Messages

  • Script to take every 5th file from a folder and copy it to another folder

    How can I tell applescript to take every 5th file of a folder of say 2000 files and copy them to another location? I want to copy the 5th, 10, 15th, 20th files and so on of 2000 files so I will have only 400 files.
    I guess I want to make a list of all the files and then coerce that to the first and then increments of five but how do I do that?
    Thanks.
    Pedro

    Hi Pedro,
    The following script should do what you are asking for:
    *set theSourceFolder to choose folder with prompt "Select the source folder."*
    *set theTargetFolder to choose folder with prompt "Select the target folder."*
    *tell application "Finder"*
    *set theFiles to files of theSourceFolder*
    *repeat with k from 5 to (count theFiles) by 5*
    *move item k of theFiles to folder theTargetFolder*
    *end repeat*
    *end tell*
    Message was edited by: Pierre L.

  • I suddenly can't move files from one folder to another in my FlashHelp project.

    I have RH8 (8.02). I have been working on this project for a couple of years now.
    What changed? I had imported a Word document and then removed the document and the folder it created from the Project Manager. Now I cannot move any of my files from one folder to another in the Project Manager pod. I susptected a corrupt CPD file so I closed the project, deleted the CPD file. Next I opened Robo from Programes (I never open from the .xpj file), went to Tools>Options and deleted the pinned most recently used project. Select Open, and locate/open the xpj file. I've also re-generated the output (no errors) and completed all these steps again. Of course Robo only goes haywire on me right before I have to publish for our new software release.

    Hi there
    From what I'm seeing my own guess here is that RoboHelp is still believing that the content belongs to word.
    I might suggest the following steps.
    Open Winows Explorer and make copies of the HTML files involved. Then from RoboHelp, delete or remove the content. Then use the Import function to add the desired HTML files back into the project into the desired folder.
    My thought is that by taking these steps you will have effectively disassociated Word and the topics should now be independent topics that RoboHelp should allow you to manage as you wish.
    Hope you get it sorted... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Unzip files from a folder which is updating regularly using multithreading

    Hi All,
    I have acode which unzip all the files from a folder .This code picks up all the zipped files at a time and then unzip it and write them to another folder but now my requirement is changed ,suppose the source folder where all the zipped files are present is refreshed or updated with new zipped files regularly then how can I implement in my code multithreading to get several files by threads and send it for unzipping.
    Please suggest with some example or edit my code.
    package com.myprojcet;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    public class Main {
         * Extracts a zip file
         public void extractZipFile() {
              try {
                   String zipFileName = "C:\\soft\\test"; //Source folder for zipped files
                   //Create input and output streams
                   File SourceDir = new File(zipFileName);
                   File[] zipFiles = SourceDir.listFiles();
                   ZipInputStream inStream = null;
                   OutputStream outStream = null;
                   ZipEntry entry;
                   byte[] buffer = new byte[1024];
                   int nrBytesRead;
                   //Get next zip entry and start reading data
              for(int i=0; i < zipFiles.length; i++) {
                   inStream= new ZipInputStream(new FileInputStream(zipFiles));
                   while((entry = inStream.getNextEntry()) != null) {
                        outStream=new FileOutputStream("C:\\soft\\test2\\"+entry.toString()); //destination folder for unzipped file
                        while ((nrBytesRead = inStream.read(buffer)) > 0) {     
                             outStream.write(buffer, 0, nrBytesRead);
                   //Finish off by closing the streams
                   outStream.close();
                   inStream.close();
              } catch (IOException ex) {
                   ex.printStackTrace();
         * @param args the command line arguments
         public static void main(String[] args) {
              new Main().extractZipFile();
    Thanks
    Sumit
    Edited by: user8687839 on Feb 27, 2012 11:00 PM

    But my question is that if in a source folder we have several files which are in zipped format and the folder is getting updated every min (say) with new zipped files (which are dumped from some outside environment).I need to unzip all the files present in the folder ,if new one comes there then also check for the new zipped file and unzip it.You don't need to keep re-stating that.
    I had written a code for unzipping a file from a folder (thinking the folder is not updated everytime).Or that.
    Now I am thinking of using threads because if I create suppose 5 threads and every threads poll the source folder and pick up a zip file ,send it for unzipping it and again poll the source folder for any new entries?Or that.
    If using the threads here hits performace then what should I use?Err, what you presently have?
    Provide me any sample code or link that would be more useful.You've already written it.

  • How do I copy printer software files from a folder on my desktop to a CD?

    How do I copy printer software files from a folder on my desktop to a CD?

    Select all the files, right click and choose burn.

  • Removed some files from library folder

    moved files from library folder and attempted to put them back after experiencing major changes and problem. This is not correcting the situation what can be done to restore it back to what it was before I started?

    Hi Ali,
    Update, I did a verify permissions with disk utility and some stuff is where it should be now, (recovered iphoto yeah) but still a problem with other things as before.
    So to answer your questions,
    What is the exact path to this folder? And please post the contents of the folder.
    I get to her old itunes by the following path;
    home>music>itunes>itunes music - this folder contains folder icons of all her old itunes library, each artist has a folder, such as amy cook>list of albums>list of songs - if selected will than open itunes and will import to new itunes library.
    I don't quite understand the heirarchy you are describing. Please post the contents of her Home folder.
    Her home folder contains
    Desktop
    Documents
    Library
    Movies
    Music
    Pictures
    plus 9 folders she had created over the past four years these are intact and accessible to proper application programs (ie documents open in appleworks, pictures are from the pictures library not iphoto, 3rd party software such as genealogy programs are intact and up to date)
    "I find some old unchanged items such as itunes, imovie, email mailbox items, in a folder that she created before the change took place in her user
    account."
    What is the exact path to this folder?
    As for this folder some things were moved back to proper places with the above mentioned verify permissions, some like, mailbox items, I was able to import to current settings to restore to how it use to be. From what I gather she created this file when things were going wrong and she feared messing the whole thing up. I access this by the following path;
    home>library>(then the folder she created) Library do not touch.
    When I compare the main library file to my account main library file they do not contain the same items in fact many of the missing items seem to be in this folder that she created. I assume the ones I need are in this file she created but I am really hesitant to just start moving things around out of fear of creating more problems on her side or messing up my side.
    If you have sufficient available disk space, you shouldn't have any problem, but you need a reliable backup, just in case.
    In regards to archive/install - sufficient available disk space meaning as much or more than what I am currently using? How do I check this to be sure?
    Which brings me to a whole new question if you have time?
    We do have an external back up system, which we used before a semi-recent move, (I plan on finding the box it is packed in believe me), however we attempted to use imacs backup program to do a quicker backup, were able to back up her side onto disks, but when I attempted to do the same on my side I received an failure error screen something about a drained buffer and being unable to perform a backup. Please tell me I have not fried my dvd drive!!!
    Thanks again, hope I answered in a way that is helpful to you.
    need to know

  • Importing All the files from a folder at a time

    Hi....
    Can any body tell me how to import set of files from a folder into IDM.
    It is becoming very difficult to import the files one after other....
    Waiting for Reply....
    Thanks in advance..........

    We used an ant script to build an XML file that will contain the files. The script is configured to use the folder structure of our CVS repository.
    We'd checkout our XML module and then run the build script and import the resulting init file.
    Code to the script is below -- caveat emptor. You'll need to change the folder structure to suit your own environment.
    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="." default="all" name="MyInit">
        <target name="init">
            <property location="." name="src.dir"/>
            <property location="." name="dest.dir"/>       
            <property name="project.name" value="${ant.project.name}"/>
            <property location="${dest.dir}/MyInit.xml" name="MyInit.output"/>
            <property name="source.configuration" value="${dest.dir}/configuration"/>       
            <property name="source.emailTemplate" value="${dest.dir}/emailTemplate"/>
            <property name="source.forms" value="${dest.dir}/forms"/>
            <property name="source.reports" value="${dest.dir}/reports"/>               
            <property name="source.resource" value="${dest.dir}/resource"/>          
            <property name="source.rules" value="${dest.dir}/rules"/>
            <property name="source.workflow" value="${dest.dir}/workflow"/>
            <!-- get the source path -->
            <path id="configuration.path">
                <fileset dir="${source.configuration}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="cp" refid="configuration.path" />
             <path id="emailTemplate.path">
                <fileset dir="${source.emailTemplate}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="ep" refid="emailTemplate.path" />
             <path id="forms.path">
                <fileset dir="${source.forms}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="fp" refid="forms.path" />
            <path id="reports.path">
                <fileset dir="${source.reports}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="rptp" refid="reports.path" />                 
            <path id="resource.path">
                <fileset dir="${source.resource}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="rep" refid="resource.path" />        
            <path id="rules.path">
                <fileset dir="${source.rules}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="rp" refid="rules.path" />
            <path id="workflow.path">
                <fileset dir="${source.workflow}" >
                   <include name="*.xml" />
                </fileset>
             </path>
             <property name="wp" refid="workflow.path" />
            <!-- get the path prefix -->
             <path id="source.path">
                <pathelement location="${src.dir}" />
             </path>
             <property name="sp" refid="source.path" />       
        </target>
        <target depends="init"  name="win_init">
            <!-- change the path of xml files to windows path -->
            <property name="importfile.path" value="${sp}"/>                            
        </target>              
        <target depends="init" name="make">
        <!-- using XML character entity references to escape
        <  <
        >  >
        '  &apos;      -->    
            <echo file="${MyInit.output}" append="false"><?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'>
    <Waveset>
    ${cp}
    ${ep}
    ${fp}
    ${rptp}
    ${rp}
    ${wp}
    </Waveset>
            </echo>
         <!-- replace path prefix with ImportCommand -->
         <replace file="${MyInit.output}"
                  token = "${sp}"
                  value = "<ImportCommand name='include' file='${importfile.path}" />
         <!-- deal with file and path separators in an os independent way -->
         <replace file="${MyInit.output}"
                  token = "${file.separator}"
                  value = "/" />        
        <replace file="${MyInit.output}"
                  token = "${path.separator}"
                  value = "${line.separator}" />
        <replace file="${MyInit.output}"
                  token = ".xml"
                  value = ".xml'/>" />
        </target>
        <target depends="init,win_init,clean,make" description="Build everything." name="all"/>
        <target depends="init" description="Clean all build products." name="clean">
            <delete file="${MyInit.output}"/>
        </target>
    </project>

  • I have installed itunes 11.0.2.26. When I delete a file or podcast I am not being prompted to delete the file from its folder at the same time.

    I have installed itunes 11.0.2.26. When I delete a file or podcast I am not being prompted to delete the file from its folder at the same time. How do I restore this facility? I am running a 64bit Windows 7 OS

    Is the media files in question in the iTunes library or elsewhere on the computer?

  • How to Copy an Image File from a Folder to another Folder

    i face the problem of copying an image file from a folder to another folder by coding. i not really know which method to use so i need some reference about it. hope to get reply soon, thx :)

    Try this code. Make an object of this class and call
    copyTo method.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
    extends File {
    public FileUtil(String pathname) throws
    NullPointerException {
    super(pathname);
    public void copyTo(File dest) throws Exception {
    File parent = dest.getParentFile();
    parent.mkdirs();
    FileInputStream in = new FileInputStream(this); //
    Open the source file
    FileOutputStream out = new FileOutputStream(dest); //
    Open the destination file
    byte[] buffer = new byte[4096]; // Create an input
    buffer
    int bytes_read;
    while ( (bytes_read = in.read(buffer)) != -1) { //
    Keep reading until the end
    out.write(buffer, 0, bytes_read);
    in.close(); // Close the file
    out.close(); // Close the file
    This is poor object-oriented design. Use derivation only when you have to override methods -- this is just
    a static utility method hiding here.

  • Is it possible to pickup a specific file from a folder?

    Hi
    I am wondering whether it is possible to pick a specific file from a folder. I have a shape where I have got a filename and I need to look for it in a folder.
    Is that possible?
    And how can I achieve this? The next step is to pick the file up and transfer it to another location. So basically in pseudo code I need to ask my defined folder with a filename as parameter. Get the file and move it to another folder.
    Suggestions are most appreciated. Thanks

    Assuming you are using orchestration, you could
    create an assembly, install it in the GAC, add a reference to it in your BTS
    project, and call it from an Expression shape to resolve the receive
    location. You would only really need one static method in a class. Be sure
    to add a reference to Microsoft.BizTalk.ExplorerOM.dll.
    Example:
    using Microsoft.BizTalk.ExplorerOM;
    namespace Phil
    public class OrchestrationHelpers
    public static string ResolveReceiveLocationName(string
    inboundTransportLocation, string receivePortName)
    BtsCatalogExplorer bts = new BtsCatalogExplorer();
    bts.ConnectionString =
    "SERVER=localhost;DATABASE=BizTalkMgmtDb;Trusted_Connection=True;Network
    Library=DBMSSOCN;"
    foreach (ReceiveLocation location in
    bts.ReceivePorts[receivePortName].ReceiveLocations)
    if (location.Address == inboundTransportLocation) return location.Name;
    return null;
    In your Expression shape within your orchestration, assuming a message
    called "MyMessage" and a string variable "receiveLocationName":
    receiveLocationName =
    Phil.OrchestrationHelpers.ResolveReceiveLocationName(MyMessage(BTS.InboundTransportLocation),
    MyMessage(BTS.ReceivePortName));
    If this post answers your question, please mark it as such. If this post is helpful, click 'Vote as helpful'.

  • How can I move a Pages file from a folder to another one?

    I Have done the upgrade to mac os Yosemite but now i'm Not able to move a file from a folder to another one Inside iCloud
    now it's impossible to organize MY archive

    Thankyou Winston, you guess right. What i don't understand is why with the older version of mac os (10.9) i can organize my document into icloud folders using the Pages app window. But now with the new version i'm no longer able to do that. Using ipad in the same window there is no problem, but in mac os it doesn't work. 

  • How to get latest added file from a folder using apple script

    Hi..
    I am trying to get a latest added file from a folder..and for this i have below script
    tell application "Finder"
        set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
        set fileName to latestFile's name
    end tell
    By using this i am not able to get latest file because for some files the creation date is some older date so is there any way to get latest file based on "Date Added" column of a folder.

    If you don't mind using GUI Scripting (you must enable access for assistive devices in the Accessibility System Preference pane), the following script should give you a reference to the last item added to any folder. Admittedly not the most elegant solution, but it works, at least under OS X 10.8.2.
    set theFolder to choose folder
    tell application "Finder"
        activate
        set theFolderWindow to container window of theFolder
        set alreadyOpen to exists theFolderWindow
        tell theFolderWindow
            open
            set theInitialView to current view
            set current view to icon view
        end tell
    end tell
    tell application "System Events" to tell process "Finder"
        -- Arrange by None:
        set theInitialArrangement to name of menu item 1 of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "0" using {control down, command down}
        -- Sort by Date Added:
        set theInitialSortingOrder to name of menu item 1 of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "4" using {control down, option down, command down}
        -- Get the name of the last item:
        set theItemName to name of image 1 of UI element 1 of last scroll area of splitter group 1 of (window 1 whose subrole is "AXStandardWindow")
        -- Restore the initial settings:
        click menu item theInitialSortingOrder of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1
        click menu item theInitialArrangement of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1
    end tell
    tell application "Finder"
        set current view of theFolderWindow to theInitialView -- restore the initial view
        if not alreadyOpen then close theFolderWindow
        set theLastItem to item theItemName of theFolder
    end tell
    theLastItem
    Message was edited by: Pierre L.

  • How can I bring a file from a folder on my desktop to this program and make it editable. Like deleti

    How can I bring a file from a folder on my desk top int this program and make it editable., in order to replace words or remove words or texts..?  jn

    Hi,
    FormsCentral cannot be used to edit existing PDF documents. That functionality is available in Adobe Acrobat:
    http://www.adobe.com/products/acrobat.html
    Regards,
    Brian

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • When importing a file from a folder

    when importing a file from a folder it appears in the organizer as a exclamation mark but no photo. can anyone help i use elements 9

    Hi there,
    Digging up an old thread slightly, but is this still definitely the case? Last week double-clicking a folder definitely just opened up a folder for me to explore its contents, but now I'm constantly accidentally importing huge folders into things like After Effects and Mail... it's very annoying!
    If there's a fix I'd love to hear it!

Maybe you are looking for

  • Capacity check in wm

    HI, I have been working on few strategies in putaway. One of the storage type which uses open storage strategy with mixed, addition to existing are allowed. With capacity check based on material. I have issue at time of creating transfer order. pleas

  • Universal WorkList (UWL) items forward

    Hi all. When a user goes to forward a workflow to someone, you get the "Forward" button. When doing the search for a person, a list is returned. Where is this list created from? We want to limit the list to be only managers, but right now, we are ret

  • Creating Query similar to excel command

    Hi Experts I have a query which outputs dataset from OITM table and includes 5 UDFs I have called TID1, TID2, TID3, TID4 and TID5. Once the query is run I then have to take it into Excel and run formula which returns the value for the last non-blank

  • 2 seconds of whirring, light click then nothing

    This happened a month ago and then suddenly all was okay. My 12" pb shutsdown. When I either press the start button or option-command-power for a reboot I only get the short whirring described in the subject line. Even if I press the power button to

  • Why do my documents disappear on my device when I delete my iCloud account?

    Why do my documents disappear on my iPad when I delete my iCloud account.  I don't want to sync all the aps from my iPhone to my iPad, so I deleted my iCloud account on my iPad, but all my documents disappeared from my iPad.  How can I get them back?