Advertisement

03.01.2008 at 01:49PM PST, ID: 23206697
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Batch file to change file names in dir to part of dir name

Tags: microsoft, MSDOS
Hi Experts
Following on from this Q
http:Q_23205499.html
I was wondering, can this batch be adapted to rename the containing file to just part of the parent directory name.
In the majority of directory names, there are parenthesis. I would want the file name changing up to including the closed parenthesis.
i.e. dir name  20080301.1200(end).5.7 - with file 12345.rpt
batch to change file to 20080301.1200(end).rpt
Many thanks
Nick
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:
@ECHO OFF
REM Remove any local variables and allow for delayed expansion.
SETLOCAL ENABLEDELAYEDEXPANSION
 
REM Change drive and directory - you will probably want to edit this.
CD /D Z:\
 
REM Iterate the directory tree, executing the rest of the FOR in each directory.
FOR /R . %%A IN (.) DO (
 
        REM Report where we are.
        ECHO Examining %%A
        
        REM Store just the name of the parent folder for later use.
        SET ParentFolder="%%~nxA"
        
        REM Initialize the file counter.
        SET FileCount=0
        
        REM Iterate the found subdirectory, counting the files and remembering the last name.
        FOR %%B IN ("%%~A"\*.RPT) DO (
                SET /A FileCount+=1
                SET FileName="%%~B"
        )
        
        REM If only 1 file was found then rename it.
        IF !FileCount! EQU 1 (
                ECHO Renaming !FileName! to !ParentFolder!.RPT
                REN !FileName! !ParentFolder!.RPT
        )
        
        REM If many files were found, then reset the counter and re-iterate the folder renaming as we go.
        IF !FileCount! GTR 1 (
                SET FileCount=0
                FOR %%B IN ("%%~A"\*.RPT) DO (
                        SET /A FileCount+=1
                        ECHO Renaming "%%~B" to !ParentFolder!_!FileCount!.RPT
                        REN "%%~B" !ParentFolder!_!FileCount!.RPT
                )
        )
)
Start your free trial to view this solution
Question Stats
Zone: OS
Question Asked By: seriousnick
Solution Provided By: RQuadling
Participating Experts: 1
Solution Grade: A
Views: 43
Translate:
Loading Advertisement...
03.01.2008 at 01:57PM PST, ID: 21023793

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.01.2008 at 02:09PM PST, ID: 21023843

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628