Sorting Files automatically

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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!!!
 
Last edited by a moderator:

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,383
39
Albuquerque, NM
prospero.unm.edu
#2
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.
 

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#3
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?
 
#4
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.
 
#6
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
 

samintz

Scott Mintz
May 20, 2008
1,203
11
Solon, OH, USA
#7
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
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
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"

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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,383
39
Albuquerque, NM
prospero.unm.edu
#10
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
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?
Charles- Exactly. There will only be 5 digit numbers in both the file and the destination subfolder.