I need a script to automate file moving according to its names rules (II)

Posted on 2006-04-17
Last Modified: 2010-05-03
I need a vbs script to make the following - inside a directory I have many files which have a similar name (only the 2 last characters are different - for example aaaa10, aaaa11, aaaa12, aaaa13; bbbb10, bbbb12, bbbb13, bbbb14). I need an automatic way to move that group of files that only have the 2 last characters different to a sub-directory with the name corresponding to common characters (for example, for aaaa10, aaaa12, aaaa13, aaaa14 it will create a sub-directory named aaaa, and aaaa10, aaaa12, aaaa13, aaaa14 will be moved inside aaaa). Can you understand what I want ? I do not know to program :( My operating system is Windows XP. If you look at you can see I have posted a similar question but the difference was only the last character... Just modify that vbs script... I wish I know to program !... Now I have no free time but in future I will learn VB ! Thanks.
Question by:asgarcymed

    Author Comment

    *) It is always two characters that are different at the end of the filenames;
    *) The common part of the names is variable (not always 4 as I used in the example);
    *) All the files are in the same folder at the same level (no recurse into subfolders needed);
    *) I want the new sub directory in the same folder as the file.
    LVL 28

    Accepted Solution

    Change this line:

        baseName = Left(file.Name, Len(file.Name) - 5)


        baseName = Left(file.Name, Len(file.Name) - 6)
    LVL 85

    Expert Comment

    by:Mike Tomlinson

    Study the code asgarcymed.  Now is a great time to start learning!

    You can find documentation on the language here:

    And documention for the File System Object classes here:

    Author Comment

    vinnyd79 - That's it, thank you a lot !

    Author Comment

    Idle_Mind  - thank your for the advices and links !

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    779 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

    12 Experts available now in Live!

    Get 1:1 Help Now