Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript to move file in one folder to many folder

Reply
 
Old 07-22-2009   #1 (permalink)
M.K


 
 

VBScript to move file in one folder to many folder

HI

I want VBscript code that check how many file in spesfic filder and move it
between 4 folder for example if the main folder has 12 files, the script will
move this 12 file to 4 subfolder and in each folder will be 3 files.



My System SpecsSystem Spec
Old 07-22-2009   #2 (permalink)
Larry Serflaten


 
 

Re: VBScript to move file in one folder to many folder


"M.K" <MK@xxxxxx> wrote
Quote:

>
> I want VBscript code that check how many file in spesfic filder and move it
> between 4 folder for example if the main folder has 12 files, the script will
> move this 12 file to 4 subfolder and in each folder will be 3 files.

That certainly is interesting. What have you tried?


My System SpecsSystem Spec
Old 07-22-2009   #3 (permalink)
M.K


 
 

Re: VBScript to move file in one folder to many folder

this what i write

ParentFolder = "C:\Users\Test\Desktop"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)
objFolder.NewFolder "1"
objFolder.NewFolder "2"
objFolder.NewFolder "3"
objFolder.NewFolder "4"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\Users\Test\Desktop\test\*.*" , "objFolder.NewFolder "1"
"2" "3" "4""

"Larry Serflaten" wrote:
Quote:

>
> "M.K" <MK@xxxxxx> wrote
Quote:

> >
> > I want VBscript code that check how many file in spesfic filder and move it
> > between 4 folder for example if the main folder has 12 files, the script will
> > move this 12 file to 4 subfolder and in each folder will be 3 files.
>
>
> That certainly is interesting. What have you tried?
>
>
>
My System SpecsSystem Spec
Old 07-23-2009   #4 (permalink)
M.K


 
 

Re: VBScript to move file in one folder to many folder

please any help

"Larry Serflaten" wrote:
Quote:

>
> "M.K" <MK@xxxxxx> wrote
Quote:

> >
> > I want VBscript code that check how many file in spesfic filder and move it
> > between 4 folder for example if the main folder has 12 files, the script will
> > move this 12 file to 4 subfolder and in each folder will be 3 files.
>
>
> That certainly is interesting. What have you tried?
>
>
>
My System SpecsSystem Spec
Old 07-23-2009   #5 (permalink)
Pegasus [MVP]


 
 

Re: VBScript to move file in one folder to many folder

I suspect that other potential respondents see the same problem with your
post as I do: Since it does not appear to be a particularly useful exercise,
it could be some homework that you are required to do for your study course.
If so then analysing your requirements in more detail will probably get you
a lot further. The following questions come to the mind:
a) Do the four target folders already exist?
b) Will there always be exactly four target folders?
c) How should the files in the source folder be distributed if there are 5,
6 or 7 files?
d) What if the target folder already has a file of the same name as the one
you're trying to move?
e) Why do you wish to develop a VB Script solution? A batch file would be
considerably simpler - it would be a mix of "md" and "move" commands, with a
loop controller thrown in.

"M.K" <MK@xxxxxx> wrote in message
news:7578FCA5-1404-4646-BA46-4B29BAAA8FE1@xxxxxx
Quote:

> please any help
>
> "Larry Serflaten" wrote:
>
Quote:

>>
>> "M.K" <MK@xxxxxx> wrote
Quote:

>> >
>> > I want VBscript code that check how many file in spesfic filder and
>> > move it
>> > between 4 folder for example if the main folder has 12 files, the
>> > script will
>> > move this 12 file to 4 subfolder and in each folder will be 3 files.
>>
>>
>> That certainly is interesting. What have you tried?
>>
>>
>>

My System SpecsSystem Spec
Old 07-24-2009   #6 (permalink)
M.K


 
 

Re: VBScript to move file in one folder to many folder

Hi,

Thnak for your reply, i do this as self learning


a) Do the four target folders already exist?
Yes,

b) Will there always be exactly four target folders?

no, some time will be more and some time will be less

c) How should the files in the source folder be distributed if there are 5,
6 or 7 files?

it divided the number of file / number of folder, but if there is more one
file it direct go first folder amd if there is 2 file more one go to first
folder and second go to second folder



d) What if the target folder already has a file of the same name as the one
you're trying to move?


overwrite, but i want if it possible the script create new folder in each
subfolder with the same name of main folder

e) Why do you wish to develop a VB Script solution? A batch file would be
considerably simpler - it would be a mix of "md" and "move" commands, with a
loop controller thrown in.


if it possible to di by both that is better for me because i do this as self
learining

"Pegasus [MVP]" wrote:
Quote:

> I suspect that other potential respondents see the same problem with your
> post as I do: Since it does not appear to be a particularly useful exercise,
> it could be some homework that you are required to do for your study course.
> If so then analysing your requirements in more detail will probably get you
> a lot further. The following questions come to the mind:
> a) Do the four target folders already exist?
> b) Will there always be exactly four target folders?
> c) How should the files in the source folder be distributed if there are 5,
> 6 or 7 files?
> d) What if the target folder already has a file of the same name as the one
> you're trying to move?
> e) Why do you wish to develop a VB Script solution? A batch file would be
> considerably simpler - it would be a mix of "md" and "move" commands, with a
> loop controller thrown in.
>
> "M.K" <MK@xxxxxx> wrote in message
> news:7578FCA5-1404-4646-BA46-4B29BAAA8FE1@xxxxxx
Quote:

> > please any help
> >
> > "Larry Serflaten" wrote:
> >
Quote:

> >>
> >> "M.K" <MK@xxxxxx> wrote
> >> >
> >> > I want VBscript code that check how many file in spesfic filder and
> >> > move it
> >> > between 4 folder for example if the main folder has 12 files, the
> >> > script will
> >> > move this 12 file to 4 subfolder and in each folder will be 3 files.
> >>
> >>
> >> That certainly is interesting. What have you tried?
> >>
> >>
> >>
>
>
>
My System SpecsSystem Spec
Old 07-24-2009   #7 (permalink)
Pegasus [MVP]


 
 

Re: VBScript to move file in one folder to many folder

Here is what I asked in my most recent reply:
c) How should the files in the source folder be distributed if there are 5,
6 or 7 files?

and here is what you answered:
Quote:

> it divided the number of file / number of folder, but if there is more one
> file it direct go first folder amd if there is 2 file more one go to first
> folder and second go to second folder
Your answer suggests that three files should go into three folders, four
files into four folders, five files into five folders etc. This contradicts
your initial specification where you said:
Quote:

> for example if the main folder has 12 files, the script will
> move this 12 file to 4 subfolder and in each folder will be 3 files.
Unless you specify very clearly what you want to do, it is not possible to
give you any good suggestions. It would also be helpful if you at least
attempted to solve the problem yourself and posted some relevant code. The
help file script56.chm (which you can download from the microsoft site) will
show you all the relevant methods of the File System Object, complete with
numerous examples.


"M.K" <MK@xxxxxx> wrote in message
news:15969D84-4F48-418C-B9EA-352C7080984A@xxxxxx
Quote:

> Hi,
>
> Thnak for your reply, i do this as self learning
>
>
> a) Do the four target folders already exist?
> Yes,
>
> b) Will there always be exactly four target folders?
>
> no, some time will be more and some time will be less
>
> c) How should the files in the source folder be distributed if there are
> 5,
> 6 or 7 files?
>
> it divided the number of file / number of folder, but if there is more one
> file it direct go first folder amd if there is 2 file more one go to first
> folder and second go to second folder
>
>
>
> d) What if the target folder already has a file of the same name as the
> one
> you're trying to move?
>
>
> overwrite, but i want if it possible the script create new folder in each
> subfolder with the same name of main folder
>
> e) Why do you wish to develop a VB Script solution? A batch file would be
> considerably simpler - it would be a mix of "md" and "move" commands, with
> a
> loop controller thrown in.
>
>
> if it possible to di by both that is better for me because i do this as
> self
> learining
>
> "Pegasus [MVP]" wrote:
>
Quote:

>> I suspect that other potential respondents see the same problem with your
>> post as I do: Since it does not appear to be a particularly useful
>> exercise,
>> it could be some homework that you are required to do for your study
>> course.
>> If so then analysing your requirements in more detail will probably get
>> you
>> a lot further. The following questions come to the mind:
>> a) Do the four target folders already exist?
>> b) Will there always be exactly four target folders?
>> c) How should the files in the source folder be distributed if there are
>> 5,
>> 6 or 7 files?
>> d) What if the target folder already has a file of the same name as the
>> one
>> you're trying to move?
>> e) Why do you wish to develop a VB Script solution? A batch file would be
>> considerably simpler - it would be a mix of "md" and "move" commands,
>> with a
>> loop controller thrown in.
>>
>> "M.K" <MK@xxxxxx> wrote in message
>> news:7578FCA5-1404-4646-BA46-4B29BAAA8FE1@xxxxxx
Quote:

>> > please any help
>> >
>> > "Larry Serflaten" wrote:
>> >
>> >>
>> >> "M.K" <MK@xxxxxx> wrote
>> >> >
>> >> > I want VBscript code that check how many file in spesfic filder and
>> >> > move it
>> >> > between 4 folder for example if the main folder has 12 files, the
>> >> > script will
>> >> > move this 12 file to 4 subfolder and in each folder will be 3 files.
>> >>
>> >>
>> >> That certainly is interesting. What have you tried?
>> >>
>> >>
>> >>
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Cannot Rename or Move a File or Folder in Vista Fix Tutorials
I want to move my Offline File Folder Vista file management
Move file to folder depending on last two characters of filename VB Script
Create New folder, move file, delete file. Explorer Freeze General Discussion
Cut & Paste, Move and Rename folder or file in the network Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46