Move files to folders based upon filename
4802
£200(approx. $250)
- Posted:
- Proposals: 12
- Remote
- #55934
- Archived
135266126914416386418881495745106239115234138033141300122127138446
Description
Experience Level: Expert
Looking for something quite simple really. I have an application that is going to write out lots of files to a particular output folder on an ongoing basis. What I want is a script (batch file) that can be run on the server (perhaps as a scheduled job) to take these files and move them into folders based upon their file name.
I want this to be as simple as possible....... a DOS based batch file for instance.... so that I can edit the input/output paths and call the program from multiple sources.
The filenames that will be found in the input folder will be structured:
Eg: APInnnn.pdf
API= Fixed value which will the 1st 3 characters in all filenames
nnnn= variable length numeric field which will expand as invoices are added (so it may start at 1 and end at 9999999999)
At the start of the script you need to have variables to store:
the path to the input folder
the path to the output folder (starting point)
To find the directory to move the pdf file into divide the numeric value (the nnnnn bit) by 5000 and the integer you arrive at is the folder that the should be save to:
API531 = would be in folder outputpath\\0 (because 531 divided by 5000 =0.1062 ……… so the path to move the file to is s:\\0\\
If the directory 0 does not exist then you need to create it.
API3294 = would be in folder outpupath\\0 (because 3294\\ divided by 5000 = 0.6588 …… the path to move the file to is s:\\0\\
If the directory 0 does not exist then you need to create it.
API6291 = would be in folder outputpath\\1 (because 6291\\ divided by 5000 = 1.2582 …… the path to move the file to is s:\\1\\
If the directory 1 does not exist then you need to create it.
Make sure that you only use the integer part of the number arrived at in the division (ie: to the left of the decimal point)…. Do not round or you will end up moving files into the wrong directory!
I want this to be as simple as possible....... a DOS based batch file for instance.... so that I can edit the input/output paths and call the program from multiple sources.
The filenames that will be found in the input folder will be structured:
Eg: APInnnn.pdf
API= Fixed value which will the 1st 3 characters in all filenames
nnnn= variable length numeric field which will expand as invoices are added (so it may start at 1 and end at 9999999999)
At the start of the script you need to have variables to store:
the path to the input folder
the path to the output folder (starting point)
To find the directory to move the pdf file into divide the numeric value (the nnnnn bit) by 5000 and the integer you arrive at is the folder that the should be save to:
API531 = would be in folder outputpath\\0 (because 531 divided by 5000 =0.1062 ……… so the path to move the file to is s:\\0\\
If the directory 0 does not exist then you need to create it.
API3294 = would be in folder outpupath\\0 (because 3294\\ divided by 5000 = 0.6588 …… the path to move the file to is s:\\0\\
If the directory 0 does not exist then you need to create it.
API6291 = would be in folder outputpath\\1 (because 6291\\ divided by 5000 = 1.2582 …… the path to move the file to is s:\\1\\
If the directory 1 does not exist then you need to create it.
Make sure that you only use the integer part of the number arrived at in the division (ie: to the left of the decimal point)…. Do not round or you will end up moving files into the wrong directory!
Shane S.
100% (11)Projects Completed
14
Freelancers worked with
3
Projects awarded
93%
Last project
1 May 2019
Ireland
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies