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

Sorting Files automatically

Discussion in 'Support' started by Matthew Randolph, Sep 29, 2014.

  1. Matthew Randolph

    Joined:
    Sep 25, 2014
    Messages:
    5
    Likes Received:
    0
    We have decided to start having our field techs use there IPhone to fill out paper work while in the field. I have chosen the software from Goformz. It easy to use and it let us upload our forms at no extra charge. I have up loaded and formatted 8 separate forms. The Goformz software ties into the online storage Box.com. I have Goformz saving a copy of the mobile forms completed into Box.com. After setting up the files online at Box.com and downloading the desktop syncing app for Box the file structure for box.com on my computer is as follows:



    C:\Users\mattr\Desktop\Box\Box Sync



    Within the folder Box Sync there are 8 folders: Air Cooled PM, Centrifugal PM, Install Tickets, Tear Down Tickets, Spot Cooler Ticket, Spot Cooler Tear Down, Safety Meeting, Service Call Ticket


    I would like to be able to have the files in the above 8 folders be sorted into our Filecenter automatically. For example:



    If the file “Install Service Ticket – 14285 J.pdf” was located in C:\Users\mattr\Desktop\Box\Box Sync\Install Tickets. I was hoping to find a program to automatically sort the file into the correct folder in Filecenter which is P:\Filecenter\2014 Jobs\14385 Adler Realty – 249 E. Ocean – Long Beach

    Is this something that I could use takecommand for? I have a very, very basic understanding of Java so obviously I would need help writing the code for it. Any and all help is much appreciated!!!
     
    #1 Matthew Randolph, Sep 29, 2014
    Last edited by a moderator: Sep 29, 2014
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    My apologies -- I edited your post to remove the external URLs, which gave the unfortunate impression that you were posting advertisements and (I think) tripped the moderation software.

    I think you'll need to post a more detailed description of how one would know which folder a given file should be sorted (copied? moved?) into.
     
  3. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,190
    Likes Received:
    11
    I assume you made a typo when you gave as your examples “Install Service Ticket – 14285 J.pdf” and "P:\Filecenter\2014 Jobs\14385 Adler Realty – 249 E. Ocean – Long Beach"

    Assuming your files all follow that naming convention: * - XXXXX* and the destination is XXXXX*, a batch script to automatically copy those files is fairly straight forward.

    Am I assuming correctly?
     
    Matthew Randolph likes this.
  4. Matthew Randolph

    Joined:
    Sep 25, 2014
    Messages:
    5
    Likes Received:
    0
    Charles - I apologize about the external links. I copied the text from an email I had sent out and forgot to remove them.

    Scott-Yes that was a typo.

    The destination Directory will look like this:
    P:\Filecenter\2006 Jobs
    P:\Filecenter\2007 Jobs
    P:\Filecenter\2008 Jobs
    P:\Filecenter\2009 Jobs
    P:\Filecenter\2010 Jobs
    P:\Filecenter\2011 Jobs
    P:\Filecenter\2012 Jobs
    P:\Filecenter\2013 Jobs
    P:\Filecenter\2014 Jobs

    All of the Jobs folders will contain somewhere between 250-500 folders with similar names as: 14385 Adler Realty – 249 E. Ocean – Long Beach "14385" in our syntax is 14 is the year and 385 is the 385th job of the year.

    So there could be a file in the Folder Install Tickets\Install Field Service Ticket - 07251.pdf that would need to be sorted into the directory P:\Filecenter\2007 Jobs\07251 Lancaster

    All Directories and Files will follow the same naming structure.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    "Lancaster" seems to have come out of thin air!
     
  6. Matthew Randolph

    Joined:
    Sep 25, 2014
    Messages:
    5
    Likes Received:
    0
    In the destination directory the last folder contains our job numbers, the customer, and usually the city it was located. I chose Lancaster because we do quite a bit of work there...haha
     
  7. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,190
    Likes Received:
    11
    You can use a DO or FOR loop to iterate over all the files you wish to copy and use regular expressions to pull the number out of the file name.
    For example:
    Code:
    echo %@rereplace[\D+(\d\d)(\d+)\D*,\1 \2,"Install Service Ticket – 14285 J.pdf"]
    14 285
    
    That regular expression says 1 or more non-numeric characters, followed by 2 digits, followed by 1 or more digits, followed by zero or more non-digits. The grouping parentheses grab the first 2 digits and the following digits.

    Code:
    do f in /a:-d *
      set yr=%@rereplace[\D+(\d\d)\d+\D*,\1 ,%f]
      set cust=%@rereplace[\D+(\d\d\d+)\D*,\1,%f]
      set job=P:\Filecenter\20%yr Jobs
     rem copy "%f" %job\%cust
    enddo
    
    I don't know how you translate the customer number into the name with address(?) following it. Where does this come from? "Adler Realty – 249 E. Ocean – Long Beach"
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    Well, if you have a path\filename with strings of particular interest in predictable places, a TCC batch file can certainly pick out those interesting strings and reassemble them into a new path\filename (and move the file).

    I believe the help is available online. Navigate to "Variable Functions Listed by Category" and then to the functions that deal with "Strings and characters". After a bit of reading you should have a rough idea of the capabilities.
     
  9. Matthew Randolph

    Joined:
    Sep 25, 2014
    Messages:
    5
    Likes Received:
    0

    The customer name and address are going to be different for every folder. If we can just sort using the job numbers that would be best.
     
  10. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    So there will only be one subfolder beginning with "14385"? The basic problem is to parse out, say, a five- or six- digit number from the original filename, find the (only) subdirectory beginning with that number, and copy the original file into it?
     
  11. Matthew Randolph

    Joined:
    Sep 25, 2014
    Messages:
    5
    Likes Received:
    0
    Charles- Exactly. There will only be 5 digit numbers in both the file and the destination subfolder.
     

Share This Page