Solved

Moving word documents automatically to a folder

Posted on 2003-11-28
8
361 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:fredmm
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
'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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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

6 Experts available now in Live!

Get 1:1 Help Now