Solved

Moving word documents automatically to a folder

Posted on 2003-11-28
8
362 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WMI, model #, retrieving information 10 113
VB6 Compile Compatibility Issue 4 87
How can i compile this github project?? 2 74
Java Loop 6 48
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now