Batch file to sort files based on file name to network drive
$30-250 USD
Closed
Posted about 12 years ago
$30-250 USD
Paid on delivery
I know this can be done, but i dont have the time or the expertise for this project.
I have read tutorials here for different situations;
[login to view URL]
[login to view URL]
Here are my files:
temp1\_For P Drive\[login to view URL] <-this is where the file will be located
temp1\_For P Drive\folder1\6228 AD [login to view URL]
temp1\_For P Drive\folder1\10711 [login to view URL]
temp1\_For P Drive\folder1\WO# 10800 [login to view URL]
temp1\_For P Drive\folder1\10778 [login to view URL]
temp1\_For P Drive\folder2\6800 [login to view URL]
And so on... (7 Folders with pdfs only)
this is a simplified version of what the folders are actually named, if needed i can give you that info also. The batch file should start with folder 1, and *attempt* to decide the folder it should go in. Each and every file will begin with a job number. It will either be 4 or 5 numbers. Sometimes it will have WO in front of it, sometime WO# and sometimes WO #, i have tried to persuade our data entry people to keep it uniform, but there may be instances where this can still happen. The files all need to be moved into their respective job folders. This, currently, is a very time consuming task. As the path could be very long, for example, P:\CURRENT JOBS\6789 - XXXXXXXXXXXXXXXXXXXXXXXXXX\Production Documents\Assemblies\PDF's\, where "XXXXX" is mostly text, but may also include commas, dashes, and underscores. However, the first 4 of the folder name are *always* going to be the job number, and this is all the information we should need. For the 5 digit jobs, the folder will *always* start with WO# followed immediately by the number (i.e. WO#10800 - XXXXXXXXXXXXXXX). There is one special case where the subfolder inside the folder actually contains the job number as well. (i.e. P:\CURRENT JOBS\6786 - XXXXXXXXXXXXXXXXXXXXXXXXXX\Production Documents\6786 In Shop Archive\Scope Reports\) I know this is redundant, and unnecessary, but this is how the file system is structured for thousands of jobs. Currently, there are 7 different folders which this batch file should process files in, and they each have a separate path for the file to be moved to the network drive.
If possible, since these files are extremely important, can we also set up error checking before the original file gets deleted, as well as any special character detection that the batch file can't handle (this is ok and understood as some files may have to be done manually) It would be preferred to have a readout at the end of the program to let the user know which files couldnt be moved, if any. And/or if everything went smoothly and/or if there were any errors.
Please let me know if all of this is possible, i think it is, i have programmed small batch files to aid in productivity, but this one is too large for me to handle. Thanks everyone for your time.
I propose completing your project by using the scripting tool Perl. This tool is ideally suited for recognizing patterns in names. My approach would be as follows:
1)Build a list of all PDF file names in the source folders
2) Extract job numbers from the filenames
3) build a list of the names of all destination folders
4)iterate through the list of PDF files and determine if the destination folder exists. If the folder does not exist, write a message to the error log.
5) check the destination folder to determine if the file to be moved already exists there. If it already exists, write a message to the error log.
6) otherwise, move each pdf file to the appropriate destination folder.
I will complete this project for $100 in one day. The deliverable will be a batch file which will be able to run on your PC.