Solved

Moving word documents automatically to a folder

Posted on 2003-11-28
8
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

733 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