Solved

Moving word documents automatically to a folder

Posted on 2003-11-28
8
363 Views
Last Modified: 2010-08-05
I have a folder that has many many word documents in it.  The documents have the following naming convention XXXXX(followed by the date and time) ex. 75432111220031423.  Our filling system is based on the last two digits of the file in this case 32.  I need to have a batch file that trims off the first 3 digits and allows me to set a criteria for a move to another folder.  So all files that are between 00 and 08 (last two digits of file) move to the 00 to 08 folder.

thanks...hope someone has some light to shed
0
Comment
Question by:fredmm
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:mvannata
ID: 9839499
Instead of using a batch job perhaps a .net windows service will be easier.  From there you can user the FileSystemWatcher object to monitor the directory.  When someone modifies (adds, renames) you can take corrective action. This way your code is can react as things are happening and not have to be a scheduled or manual process.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9849245
you can use wsh to do this task easily.
if you are aware of vbscripting tell me I shall provide u an example u can build on top of it else give me the following inputs
the file name format
the destination dir the one aboev 00 to 08 etc
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 125 total points
ID: 9849389
Dim fso, f
Dim sourceDir
sourceDir="d:\temp"
Dim destDir
destDir="d:\temp1"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sourceDir)
dim i
for each x in f.files
      x.move destDir & "\" & mid(x.name,4,2) & "\" & x.name
next
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 9

Expert Comment

by:bhagyesht
ID: 9849392
copy the above code save it as a vbs and replace the soruce and the destination dir with valid names double click to execute
0
 

Author Comment

by:fredmm
ID: 9850169
Thanks bhagyesht ...but it doesnt seem to run. ... am i just having monday morning blues..or... your x was never declared..that a problem?
0
 

Author Comment

by:fredmm
ID: 9850450
OK ... sorry..slow this am ...i see that you dim i ..i assume that should be an x.

This is an example of the file name

41487-NP_Patentexamrprt_031006115431.doc

I want to move that file to a folder such as c:\80 to 90\submissions\files ..of course if the file number was            
41423-NP_Patentexamrprt_031006115431.doc I would want it moved to 20-30 (the last two digits of the first first five.

Hope that makes sense.  When I run your code I get the following message ..path not found.
0
 

Author Comment

by:fredmm
ID: 9850714
OK this is what I have and I am pretty sure its what I need (a start but finishing will not be a problem.....thanks for the help
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9855659
'VBscript doesnt require variable declaration
' you may be getting the error since you might not have substituted the sourcedir and dest dir with actual values
'as written



Dim fso, f
Dim sourceDir
sourceDir="d:\temp"
Dim destDir2030
destDir="d:\temp1\20 - 30\submissions\files"
Dim destDir3040
destDir="d:\temp1\30 - 40\submissions\files"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sourceDir)

for each x in f.files
      if cint(mid(x.name,4,2)) >=20 and cint(mid(x.name,4,2)) <=30 then
            x.movefile destDir2030 & "\" & x.name
      elseif cint(mid(x.name,4,2)) >=20 and cint(mid(x.name,4,2)) <=30 then
            x.movefile destDir3040 & "\" & x.name
      end if
next



simarlily add for the other segments ie 40-5- and so on
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exe program is not a valid Win 32 application 15 108
Controlled Assessment GCSE - desperate help needed 4 84
Windows Service to Receive TCP Packets 4 144
Apps blocked by Java 9 79
This is about my first experience with programming Arduino.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question