Asp.net file batch rename Program

Source: Internet
Author: User

Asp.net file batch rename Program

Several hundred images were taken in batches using CCD, named as 1.bmp, 2.bmp, and 3.bmp... , In order, because some images are blurred or non-conforming

Condition, I manually remove it, so with the problem mentioned just now, a large number of image file names are not continuous, and it is not convenient to use Matlab for processing. So I wrote a C # applet to automatically arrange images.

I'm a cainiao. If you have better solutions and algorithms, please advise me a lot. The Code is as follows:

1 using System;

2 using System. Collections. Generic;

3 using System. Text;

4 using System. IO;

5 using System. Windows. Forms;

6 // automatically rename

7 namespace renamebmp

8 {

9 class Program

10 {

11 static void Main (string [] args)

12 {

13 int first = 1; // start Image number

14 int last = 301; // end image number

15 int temp;

16 string path1; // The first empty position found

17 string path2; // the path of the image file with the minimum serial number after the empty position found

18 int count = 0; // number of images

19 string temppath = "";

20 for (int k = first; k <= last; k ++)

21 {

22 temppath = "F: \ test6 \" + k. ToString () + ". bmp ";

23 if (File. Exists (temppath ))

24 count ++;

25}

26 for (int I = first; I <= count; I ++)

27 {

28 temp = I + 1;

29 path1 = "F: \ test6 \" + I. ToString () + ". bmp ";

30 if (! File. Exists (path1 ))

 

31 {

32 path2 = "F: \ test6 \" + temp. ToString () + ". bmp ";

33 while (! File. Exists (path2 ))

34 {

35 temp ++;

36 if (temp = last)

37 {

38 path2 = "F: \ test6 \" + last. ToString () + ". bmp ";

39 break;

40}

41 path2 = "F: \ test6 \" + temp. ToString () + ". bmp ";

42}

43 File. Move (path2, path1); // use the move method to rename

44}

45}

46 MessageBox. Show ("after sorting, the number of images after sorting is" + count. ToString ());

47}

48}

49}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.