?
Solved

Moving word documents automatically to a folder

Posted on 2003-11-28
8
Medium Priority
?
368 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 375 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 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