Web Images News Groups Scholar Blogs Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Move n files sort by Filename
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 26 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bals  
View profile  
 More options Nov 6, 12:38 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Bals <balamurugan.mr....@gmail.com>
Date: Fri, 6 Nov 2009 04:38:46 -0800 (PST)
Local: Fri, Nov 6 2009 12:38 pm
Subject: Move n files sort by Filename
I have many files in a folder - I need to move only first 5 files
another folder sort by filename
ie  in Source folder i have
1Filename.txt
2Filename.txt
3Filename.txt
4Filename.txt
5Filename.txt
6Filename.txt
7Filename.txt
8Filename.txt
9Filename.txt

I need to move only FIRST 5 files sort by Filename to destination
folder
1Filename.txt
2Filename.txt
3Filename.txt
4Filename.txt
5Filename.txt

Please give me a sample script for this


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 6, 2:28 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 15:28:01 +0100
Local: Fri, Nov 6 2009 2:28 pm
Subject: Re: Move n files sort by Filename

"Bals" <balamurugan.mr....@gmail.com> wrote in message

news:b7cdd336-ef14-42bb-8cc5-979ecd986b49@k19g2000yqc.googlegroups.com...

You could use this simple batch file:
@echo off
SetLocal EnableDelayedExpansion
set Source=d:\Source Folder
set Target=d:\Target Folder
set count=0
if not exist "%Source%" (
  echo Cannot find the folder "%Source%"
  pause
  goto :eof
)
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('dir /on /b /a-d "%Source%"') do (
  echo Moving "%Source%\%%a"
  rem move /y "%Source%\%%a" "%Target%"
  set /a count=!count! + 1
  if !count! GEQ 5 goto :eof
)

Remove "rem" in the fourth line from the bottom to activate the batch file.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 6, 3:14 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Fri, 6 Nov 2009 10:14:44 -0500
Local: Fri, Nov 6 2009 3:14 pm
Subject: Re: Move n files sort by Filename
  You didn't explain what makes those files "first".
If they're recognizable by name then you can just
use MoveFile. Are you familiar with the FileSystemObject?
It provides a number of file handling functions.
First create the object:

Set FSO = CreateObject("Scripting.FileSystemObject")

' The MoveFile method is like this:

FSO.MoveFile "C:\here\file1.txt", "C:\there\file1.txt"

However, MoveFile is prone will error out if the
desitnation file exists, so it's a good idea to do:

If FSO.FileExists("C:\there\file1.txt") Then FSO.DeleteFile
"C:\there\file1.txt", True

FSO.MoveFile "C:\here\file1.txt", "C:\there\file1.txt"

  You can find all of this in the Windows Script
documentation.
  If you need to first find the files that's a different
matter, but from your post it sounds like that's not
an issue.

--
--

Bals <balamurugan.mr....@gmail.com> wrote in message

news:b7cdd336-ef14-42bb-8cc5-979ecd986b49@k19g2000yqc.googlegroups.com...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 6, 3:18 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Fri, 6 Nov 2009 10:18:09 -0500
Local: Fri, Nov 6 2009 3:18 pm
Subject: Re: Move n files sort by Filename
   Also, if you're new to this and trying to learn
VBScript, you need to understand that the code
from Pegasus is not VBScript. Apparently his code
will work, but it's actually DOS, which is an
entirely different thing.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 6, 3:37 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 16:37:55 +0100
Local: Fri, Nov 6 2009 3:37 pm
Subject: Re: Move n files sort by Filename

"mayayana" <mayaXXy...@rcXXn.com> wrote in message

news:uxrJlQvXKHA.1236@TK2MSFTNGP05.phx.gbl...

>   Also, if you're new to this and trying to learn
> VBScript, you need to understand that the code
> from Pegasus is not VBScript. Apparently his code
> will work, but it's actually DOS, which is an
> entirely different thing.

You're entirely correct: It is not VB Script. However, it is not DOS either
but a batch file. DOS is a legacy operating system (not a scripting tool)
that does not exist under the current 32/64-bit operating systems - unless
you choose to call any character based black screen "DOS". With this
measure, some Unix/Linux screens would equally qualify as "DOS". Now before
you rub my nose in it, yes, I know, a number of Microsoft programmers are
not aware of the distinction either: Their published documentation refers to
all character-based black screens as "DOS screens". They're probably the old
breed.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 6, 4:12 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Fri, 6 Nov 2009 11:12:36 -0500
Local: Fri, Nov 6 2009 4:12 pm
Subject: Re: Move n files sort by Filename

> You're entirely correct: It is not VB Script. However, it is not DOS
either
> but a batch file.

    A "batch" file in what language? A powershell
file? An updated DOS that still uses .bat extension?

   Frankly I don't care what it is. It's not VBScript
and this is a VBScript group. I have a lot of experience
with VBScript, I'm here in the VBS group,
and I only vaguely understand the code you posted.
I have no idea what file extension it should have, or
what dependencies it has. And if I look up your code
in the WSH Scripting help file I don't see it. If I save
it in a .vbs file and run it it doesn't work.

  Yet you posted it here with no explanation.

   I don't understand why you feel a need to
systematically post in the wrong group. But
more than that, I don't understand why you
don't at least explain what you're posting.
Bals appears to be a new scripter. Imagine
if you were new to C++, asked a question in
a C++ group, and got a code sample in Java with
no explanation. Don't you think that might be
awfully confusing and time-wasting for you?

   How can you think that your DOS-esque batch
code is more relevant in a VBS group than, say,
javascript or perl? (At least those languages are
well suited to *Windows* scripting. But they're
still completely OT.)

   If you'd at least explain it clearly then I wouldn't
have to, and then you won't need to get annoyed
that I call it DOS. I'm just asking that you have some
regard for what the OP actually needs.
  (Sticking to on-topic responses would be very nice,
too, but that's probably asking too much. You seem
oddly intent on selling DOS-esque to anyone and
everyone, without regard to common courtesies or
newsgroup rules.)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 6, 5:46 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 18:46:38 +0100
Local: Fri, Nov 6 2009 5:46 pm
Subject: Re: Move n files sort by Filename

"mayayana" <mayaXXy...@rcXXn.com> wrote in message

news:O0XCBvvXKHA.1268@TK2MSFTNGP04.phx.gbl...

>> You're entirely correct: It is not VB Script. However, it is not DOS
> either but a batch file.

>    A "batch" file in what language? A powershell
> file? An updated DOS that still uses .bat extension?

>   Frankly I don't care what it is. It's not VBScript
> and this is a VBScript group. I have a lot of experience
> with VBScript, I'm here in the VBS group,
> and I only vaguely understand the code you posted.
> I have no idea what file extension it should have, or
> what dependencies it has. And if I look up your code
> in the WSH Scripting help file I don't see it. If I save
> it in a .vbs file and run it it doesn't work.

*** Have you thought of broadening your horizon a little?

>  Yet you posted it here with no explanation.

>   I don't understand why you feel a need to
> systematically post in the wrong group. But
> more than that, I don't understand why you
> don't at least explain what you're posting.

*** I occasionally post batch files here and I occasionally
*** post VB Script files in a batch group. The reason is
*** that sometimes batch files are more effective than
*** VB Script files and sometimes it's the other way
*** round. This is one of them: The OP wants the first
*** few files moved, where "first" means by file name
*** (which he said but which you appear to have missed).
*** In a batch file a file sort is effected with a simple
*** switch. In VB Script you have to write a sort routine.
***
*** If the OP would like an explanation of the code then
*** I'll gladly give it to him.

> Bals appears to be a new scripter. Imagine
> if you were new to C++, asked a question in
> a C++ group, and got a code sample in Java with
> no explanation. Don't you think that might be
> awfully confusing and time-wasting for you?

*** You're clutching at straws. Batch files will run on any
*** Windows machine. They are universal. For Bals you
*** probably need to install some interpreter.

>   How can you think that your DOS-esque batch
> code is more relevant in a VBS group than, say,
> javascript or perl?

*** I don't but I think it's a very effective solution in this
*** particular case. And it does not like an add-on
*** interpreter like perl does.

> (At least those languages are
> well suited to *Windows* scripting. But they're
> still completely OT.)

>   If you'd at least explain it clearly then I wouldn't
> have to, and then you won't need to get annoyed
> that I call it DOS.

*** I'm not getting annoyed - I simply and factually pointed out
*** that in current usage nmy file is a batch file, not a DOS file.
*** In view your lengthy response I suspect that it's you who's
*** getting rather rattled about this minor issue.

> I'm just asking that you have some
> regard for what the OP actually needs.

*** He got a solution that is universal and that works.

>  (Sticking to on-topic responses would be very nice,
> too, but that's probably asking too much. You seem
> oddly intent on selling DOS-esque to anyone and
> everyone, without regard to common courtesies or
> newsgroup rules.)

*** I'm pragmatic and I use the solution that I consider
*** most effective. Look at the size of your code after
*** you have included the sort routine, then compare
*** it with the batch file. The batch file will be much tighter,
*** yet perfectly understandable if you have a basic knowledge
*** of console command (with the exception of one line of code).
*** Same for the respective code explanations. The fact is that
*** when it comes to copying or moving files, there is a lot of very
*** powerful stuff built into standard console commands. With VB
*** Scripts you often have to write your own code to achieve the
*** same aim. I call it "re-inventing the wheel".

*** Sometimes posters ask specifically for a VB Script solution,
*** e.g. as a learning experience. In those cases I agree with you:
*** It would be totally inappropriate to give them a batch answer.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 6, 7:03 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Fri, 6 Nov 2009 14:03:10 -0500
Local: Fri, Nov 6 2009 7:03 pm
Subject: Re: Move n files sort by Filename

> You're entirely correct: It is not VB Script. However, it is not DOS
either
> but a batch file. DOS is a legacy operating system (not a scripting tool)

    I got curious about this and looked it
up, since the topic of exactly what "batch"
code is keeps coming up. Maybe this will
provide some clarification for anyone who's
interested:

  In general, batch refers to pre-GUI scripting
(as opposed to *Windows* scripting). It is
command-line, run by the local console
interpreter, though it can also be written to files.
Thus "batch" -- running numerous commands
in series.

  On Win9x it's DOS commands, run by command.com.

  The posted code will not run on Win9x. It's limited
to NT. On NT the system of DOS commands was
expanded and updated, intrerpreted by cmd.exe
instead of command.com. The newer "DOS+" is
now known as "NT Command Script". It appears
to be a superset, including all of the DOS commands
with more commands added. There is a Microsoft
newsgroup here:

microsoft.public.win2000.cmdprompt.admin

   NT Command Script code is apparently best
saved with .cmd extension when used from a file
because if saved as a .bat file it will be misinterpreted
on Win9x. But from what I read it appears that
either extension will -- on NT systems -- be run
by cmd.exe.

Reference:
http://en.wikipedia.org/wiki/Batch_file


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 6, 7:27 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 20:27:16 +0100
Local: Fri, Nov 6 2009 7:27 pm
Subject: Re: Move n files sort by Filename

"mayayana" <mayaXXy...@rcXXn.com> wrote in message

news:O7jQUOxXKHA.4816@TK2MSFTNGP06.phx.gbl...

I completely agree with everything you say. Let me add one minor point: The
newsgroup you quote (microsoft.public.win2000.cmdprompt.admin) is a sleepy
hollow. Batch action is really here: alt.msdos.batch.nt. It is where I
occasionally post VB Script code, eg. this one where a batch file solution
would have been extremely slow and quite fragile. VB Script is an excellent
solution in this case.
http://groups.google.com/group/alt.msdos.batch.nt/browse_thread/threa...

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bals  
View profile  
 More options Nov 9, 12:40 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Bals <balamurugan.mr....@gmail.com>
Date: Mon, 9 Nov 2009 04:40:10 -0800 (PST)
Local: Mon, Nov 9 2009 12:40 pm
Subject: Re: Move n files sort by Filename
Thanks Mayayana ,
Yeah I am new to VBScript , I know the basics n FSO on VBScript.
I can Use For each loop to move files .
All I want is to move First 5 files sort by filename

set fileSys=CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
sIncomingFolder = "D:\Temp\BulkUpload\Incoming\"
sBulkFolder = "D:\Temp\BulkUpload\BulkUpload\"

Set folder = fso.GetFolder(sBulkFolder)
Set files = folder.Files
For each folderIdx In files
call fileSys.Movefile(sIncomingFolder &folderIdx.Name, sBulkFolder )
Exit For
End If

Say My sIncomingFolder  has 9 files
HHHH.txt
JJJJJ.txt
AAAA.txt
BBBB.txt
CCCC.txt
DDDD.txt
EEEE.txt
FFFF.txt
GGG.txt

I need to move only 5 files sort by file name to sBulkFolder
AAAA.txt
BBBB.txt
CCCC.txt
DDDD.txt
EEEE.txt


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard.Williams.20  
View profile  
 More options Nov 9, 2:38 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Richard.Williams.20" <richard.williams...@gmail.com>
Date: Mon, 9 Nov 2009 06:38:40 -0800 (PST)
Local: Mon, Nov 9 2009 2:38 pm
Subject: Re: Move n files sort by Filename
On Nov 9, 7:40 am, Bals <balamurugan.mr....@gmail.com> wrote:

Very nice dialog so far - I learnt a few things.

Now, for moving first 5 files (sorted by name order) from C:/
sIncomingFolder to C:/sBulkFolder, here is a script - Err, I wrote a
more general script - it moves n files from infolder to outfolder.

# Script MoveNFiles.txt
# Input arguments
var str infolder, outfolder
var int n
# Get list of all *.txt files, sorted by name
var str list ; lf -n "*.txt" $infolder > $list
# Get first n files one by one and move them
var int count
while ($count < $n)
do
    # Get the next top file from the list
    var str file ; lex "1" $list > $file
    # It is possible there may not be n files in the list.
    # In that case, $file will be empty.
    if ($file <> "")
    do
        # Move file.
        system move $file $outfolder
    done
    # Increment $count
    set $count = $count + 1
done

Script is in biterscripting. Save it in file C:/Scripts/
MoveNFiles.txt. Call it as follows.

script "C:/Scripts/MoveNFiles.txt" n(5) infolder("C:/sIncomingFolder")
outfolder("C:/sBulkFolder")

Above will move first 5 (sorted by name) from C:/sIncomingFolder to C:/
sBulkFolder.

The commands I am using are lf (list files) and lex (line extract).
Their man pages are at http://www.biterscripting.com/helppages/lf.html
and http://www.biterscripting.com/helppages/lex.html


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 9, 2:51 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Mon, 9 Nov 2009 09:51:51 -0500
Local: Mon, Nov 9 2009 2:51 pm
Subject: Re: Move n files sort by Filename
  OK, so you want to do it alphabetically.
I think if it were me I'd get the file names
into an array:

Dim AFils(), i2
i2 = 0
Set files = folder.Files
  Redim AFils(files.count - 1)
    For each folderIdx In files
      AFils(i2) = folderIdx.Name
      i2 = i2 + 1
    next
  Redim Preserve AFils(i2 - 1)
Set files = Nothing

' Then sort the array. (See QuickSort Sub below):

QuickSort AFils, 0, 0

' Now move the files:

If Right(sBulkFolder, 1) <> "\" then sBulkFolder = sBulkfolder & "\"

For i2 = 0 to 4
   FSO.MoveFile sBulkFolder & AFils(i2), OtherPlace & AFils(i2)
Next

' The above is "air code" with no error trapping
' for things like an empty folder or an existing
' destination file.

' Here's the sorting routine. AIn is the array to
' sort. When the sub is finished the array is sorted.

Sub QuickSort(AIn, LBeg, LEnd)
  Dim LBeg2, vMid, LEnd2, vSwap
      If (LEnd = 0) Then LEnd = UBound(AIn)
  LBeg2 = LBeg
  LEnd2 = LEnd
  vMid = UCase(AIn((LBeg + LEnd) \ 2))
   Do
     Do While UCase(AIn(LBeg2)) < vMid And LBeg2 < LEnd
        LBeg2 = LBeg2 + 1
     Loop
     Do While vMid < UCase(AIn(LEnd2)) And LEnd2 > LBeg
         LEnd2 = LEnd2 - 1
     Loop
       If LBeg2 <= LEnd2 Then
          vSwap = AIn(LBeg2)
          AIn(LBeg2) = AIn(LEnd2)
          AIn(LEnd2) = vSwap
          LBeg2 = LBeg2 + 1
          LEnd2 = LEnd2 - 1
       End If
  Loop Until LBeg2 > LEnd2
   If LBeg < LEnd2 Then QuickSort AIn, LBeg, LEnd2
   If LBeg2 < LEnd Then QuickSort AIn, LBeg2, LEnd
End Sub


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 9, 3:37 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Mon, 9 Nov 2009 10:37:19 -0500
Local: Mon, Nov 9 2009 3:37 pm
Subject: Re: Move n files sort by Filename

> Script is in biterscripting. Save it in file C:/Scripts/
> MoveNFiles.txt. Call it as follows.

  And apparently one has to pay for a 3rd-party
library to use this biterscripting? I would be
a bit leery of using a Windows scripting tool
written by people who think Windows uses Unix
syntax in file paths.

  But your post has cheered me up, anyway.
It makes NT Command Script posts seem
relevant and useful by comparison. :)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 9, 3:58 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Mon, 9 Nov 2009 16:58:14 +0100
Local: Mon, Nov 9 2009 3:58 pm
Subject: Re: Move n files sort by Filename

"mayayana" <mayaXXy...@rcXXn.com> wrote in message

news:u$IURJVYKHA.4452@TK2MSFTNGP04.phx.gbl...

>> Script is in biterscripting. Save it in file C:/Scripts/
>> MoveNFiles.txt. Call it as follows.

>  And apparently one has to pay for a 3rd-party
> library to use this biterscripting? I would be
> a bit leery of using a Windows scripting tool
> written by people who think Windows uses Unix
> syntax in file paths.

>  But your post has cheered me up, anyway.
> It makes NT Command Script posts seem
> relevant and useful by comparison. :)

Grin :)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bals  
View profile  
 More options Nov 10, 3:45 am
Newsgroups: microsoft.public.scripting.vbscript
From: Bals <balamurugan.mr....@gmail.com>
Date: Mon, 9 Nov 2009 19:45:14 -0800 (PST)
Local: Tues, Nov 10 2009 3:45 am
Subject: Re: Move n files sort by Filename
Thanks All . This has helped me lot.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Al Dunbar  
View profile  
 More options Nov 10, 5:32 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Al Dunbar" <aland...@hotmail.com>
Date: Mon, 9 Nov 2009 22:32:34 -0700
Local: Tues, Nov 10 2009 5:32 am
Subject: Re: Move n files sort by Filename

"Pegasus [MVP]" <n...@microsoft.com> wrote in message

news:eOzPZkwXKHA.960@TK2MSFTNGP04.phx.gbl...

This may be true, however, I agree with mayayana that, when posting a
solution based on a language other than the one on which this newsgroup is
based, you should put your OT response in a proper context. And this is even
more true when dealing with newbies, some of whom I have seen trying to run
provided batch solutions in .vbs files.

> *** This is one of them: The OP wants the first
> *** few files moved, where "first" means by file name
> *** (which he said but which you appear to have missed).
> *** In a batch file a file sort is effected with a simple
> *** switch. In VB Script you have to write a sort routine.

True enough. But I disagree with your interpretation of what the OP actually
wanted.

> *** If the OP would like an explanation of the code then
> *** I'll gladly give it to him.

>> Bals appears to be a new scripter. Imagine
>> if you were new to C++, asked a question in
>> a C++ group, and got a code sample in Java with
>> no explanation. Don't you think that might be
>> awfully confusing and time-wasting for you?
> *** You're clutching at straws.

No he's not, what he says makes perfect sense to me.

> *** Batch files will run on any
> *** Windows machine. They are universal. For Bals you
> *** probably need to install some interpreter.

Bals is the OP, not some alternative scripting language. Bals asked for a
solution in a vbscript group. I assume that he is more interested in
learning how to do this in vbscript than in getting a solution handed to him
in some other language. In that scenario, no optional interpreter
installation would be required.

And although batch files do run on all windows versions, the batch language
itself differs from windows version to windows version, to the extent that a
batch file that works on, say, NT2000, could easily fail to give the same
results on a Windows 98 system.

At the very least, I think it fair to assume that someone posting in a
vbscript group is using an operating system where that is applicable.

>>   How can you think that your DOS-esque batch
>> code is more relevant in a VBS group than, say,
>> javascript or perl?
> *** I don't but I think it's a very effective solution in this
> *** particular case. And it does not like an add-on
> *** interpreter like perl does.

If you don't think your batch contribution is more relevant here than a
vbscript one, why insist on posting it here?

>> (At least those languages are
>> well suited to *Windows* scripting. But they're
>> still completely OT.)

>>   If you'd at least explain it clearly then I wouldn't
>> have to, and then you won't need to get annoyed
>> that I call it DOS.
> *** I'm not getting annoyed - I simply and factually pointed out
> *** that in current usage nmy file is a batch file, not a DOS file.
> *** In view your lengthy response I suspect that it's you who's
> *** getting rather rattled about this minor issue.

Who is more rattled is not the issue. The issue is OT posting.

>> I'm just asking that you have some
>> regard for what the OP actually needs.
> *** He got a solution that is universal and that works.

Correction. You provided a solution that you think he wants. His next
response would seem to indicate more of an interest in learning how to do
this in vbscript.

I use batch and vbscript. A comparison of their relative merits is generally
OT in a newsgroup devoted to one of them, except when that has been
specifically asked for.

> *** Sometimes posters ask specifically for a VB Script solution,
> *** e.g. as a learning experience. In those cases I agree with you:
> *** It would be totally inappropriate to give them a batch answer.

I would propose that the default solution language here should be assumed to
be vbscript, and that alternate solutions should be provided only in those
cases where the OP specifically states that he is interested.

/Al


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Watkins  
View profile  
 More options Nov 10, 8:33 am
Newsgroups: microsoft.public.scripting.vbscript
From: "James Watkins" <some...@microsoft.com>
Date: Tue, 10 Nov 2009 19:33:46 +1100
Local: Tues, Nov 10 2009 8:33 am
Subject: Re: Move n files sort by Filename

"Bals" <balamurugan.mr....@gmail.com> wrote in message

news:08bd8fed-1066-4087-807a-4fadcaee35c8@b15g2000yqd.googlegroups.com...

> Thanks All . This has helped me lot.

It might be useful to give a summary of this intriguing thread in which Bals
asked for a sample script to move some files.

Pegasus supplied a 17-line batch file solution even though this is a VB
Script forum.

Mayana attacked Pegasus for posting a batch file in a VB Script group, then
supplied a 54-line VB Script solution.

Richard Williams proposed a 22-line solution that requires the installation
of biterscripting.

Al Dunbar did not supply any solution but attacked Pegasus for posting batch
files in a VB Script newsgroup.

Bals acknowledged the help he had received.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Vargo  
View profile  
 More options Nov 10, 11:36 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Todd Vargo" <tlva...@sbcglobal.netz>
Date: Tue, 10 Nov 2009 06:36:45 -0500
Local: Tues, Nov 10 2009 11:36 am
Subject: Re: Move n files sort by Filename

That would be par for the course.
You learnt well grasshopper.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bigroy  
View profile  
 More options Nov 10, 8:41 pm
Newsgroups: microsoft.public.scripting.vbscript
From: bigroy <roy.ca...@gmail.com>
Date: Tue, 10 Nov 2009 12:41:55 -0800 (PST)
Local: Tues, Nov 10 2009 8:41 pm
Subject: Re: Move n files sort by Filename
On Nov 10, 11:36 am, "Todd Vargo" <tlva...@sbcglobal.netz> wrote:

Very interesting topic - does anyone know why "For each folderIdx In
files" doesnt process files in alphabetical order?
What order does it process them in?

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Vargo  
View profile  
 More options Nov 10, 9:57 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Todd Vargo" <tlva...@sbcglobal.netz>
Date: Tue, 10 Nov 2009 16:57:39 -0500
Local: Tues, Nov 10 2009 9:57 pm
Subject: Re: Move n files sort by Filename

bigroy wrote:

> Very interesting topic - does anyone know why "For each folderIdx In
> files" doesnt process files in alphabetical order?
> What order does it process them in?

Yes, the FOR command processes files in the order in which they are stored.
To force processing in alphabetical order, you can use the extended /F
feature of FOR command to process a DIR/A-D/ON directory listing.

FOR /f "delims=" %%g in ('DIR/A-D/ON/B') do echo %%g

See the FOR/? and DIR/? help for more information.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pegasus [MVP]  
View profile  
 More options Nov 10, 10:55 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Tue, 10 Nov 2009 23:55:23 +0100
Local: Tues, Nov 10 2009 10:55 pm
Subject: Re: Move n files sort by Filename

"Todd Vargo" <tlva...@sbcglobal.netz> wrote in message

news:ubEZNDlYKHA.4932@TK2MSFTNGP02.phx.gbl...

I thought that this was a VB Script group, that "bigroy" asked a VB Script
question and that "for each" requires not a switch but a separate sort
process? :-)

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Al Dunbar  
View profile  
 More options Nov 11, 12:28 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Al Dunbar" <aland...@hotmail.com>
Date: Tue, 10 Nov 2009 17:28:52 -0700
Local: Wed, Nov 11 2009 12:28 am
Subject: Re: Move n files sort by Filename

"Todd Vargo" <tlva...@sbcglobal.netz> wrote in message

news:uIkVQofYKHA.2188@TK2MSFTNGP04.phx.gbl...

LOL! But I would disagree with the word "attacked". Can we not express
disagreement without it being seen as an attack?

/Al


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Nov 11, 12:54 am
Newsgroups: microsoft.public.scripting.vbscript
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Tue, 10 Nov 2009 19:54:36 -0500
Local: Wed, Nov 11 2009 12:54 am
Subject: Re: Move n files sort by Filename

Very interesting topic - does anyone know why "For each folderIdx In
files" doesnt process files in alphabetical order?
What order does it process them in?


  It's a collection. I think they're listed in order
by date, but I'm not certain. It's returning them
the way the file system sees them.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Vargo  
View profile  
 More options Nov 11, 4:14 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Todd Vargo" <tlva...@sbcglobal.netz>
Date: Tue, 10 Nov 2009 23:14:27 -0500
Local: Wed, Nov 11 2009 4:14 am
Subject: Re: Move n files sort by Filename

But I though this was a post whatever code you want thread. ;-)

BTW, as long as we are discussing posting habits, when did it become
customary to quote sigs when responding? :-O

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Watkins  
View profile  
 More options Nov 11, 10:31 am
Newsgroups: microsoft.public.scripting.vbscript
From: "James Watkins" <some...@microsoft.com>
Date: Wed, 11 Nov 2009 21:31:10 +1100
Local: Wed, Nov 11 2009 10:31 am
Subject: Re: Move n files sort by Filename

"Todd Vargo" <tlva...@sbcglobal.netz> wrote in message

news:eGZWVmoYKHA.1640@TK2MSFTNGP06.phx.gbl...

You sound a little miffed, pal.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 26   Newer >
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google