[Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-04-17
Medium Priority
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 http://www.experts-exchange.com/Programming/Q_21812622.html 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
  • 3

Author Comment

ID: 16468906
*) 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

vinnyd79 earned 1400 total points
ID: 16469077
Change this line:

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


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

Expert Comment

by:Mike Tomlinson
ID: 16469138

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

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

Author Comment

ID: 16469157
Idle_Mind  - thank your for the advices and links !

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

864 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