move directories and files that exist in a sub folder - problem
- From: Firewalker82 <Firewalker82@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 2 Aug 2008 11:49:03 -0700
Hi all,
I am trying to create an automated script that searches in a sub directory
for files and directories. Once it counts if any exist, it creates a sub
directory and moves these files and directories into it. I am having
problems trying to achieve this as it is not as straight forward as I
initially thought as you have to first of all search for files in a function
and then search for directories in a seperate function as I have not seen an
object that does both types (pretty much like a dir, although I want to use
the fso).
Ultimately I want to be able to store the paths of all the files and
directories that the fso object finds in an array and then enumerate through
this in a for each and move these into another directory. Check out my
script idea below;
Dim fso, f, f1, fc, s, folderspec
Set fso = CreateObject("Scripting.FileSystemObject")
folderspec = "C:\scripts\test"
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
countf = fc.count
set fd = f.subfolders
countd = fc.count
fldr = "C:\scripts\test\my documents"
'Check to see whether the my documents folder exists
mydocsexists = fso.FolderExists(fldr)
if mydocsexists = "False" then
'Check to see if any files exist
if countf <> 0 then
'Move all Files
For Each fitem in fc
file = file & fitem.path & VBCRLF
Next
end if
'Check to see if any directories exist
if countd <> 0 then
'Move All Directories
For Each ditem in fd
folder = ditem.path
next
end if
'Create my documents folder
fso.createfolder("C:\Scripts\Test\My Documents")
'Here I would like to enumerate through the folder and file variables
'That were collected earlier and move the files into the my documents
folder above
'I get an error when I try and read a for each variable thats not a
collection
' How do i create a collection for this information?
end if
Thanks
--
Firewalker82
.
- Follow-Ups:
- Prev by Date: Re: regular expression help
- Next by Date: Re: regular expression help
- Previous by thread: regular expression help
- Next by thread: Re: move directories and files that exist in a sub folder - problem
- Index(es):
Relevant Pages
|
Loading