Batch command rename

Source: Internet
Author: User
Code
1 @ echo on
2 setlocal enabledelayedexpansion
3CD F: \ movie \ complete video set
4dir *. srt/S/a-d/B> temp.txt
5
6 set filename = ""
7 set tempname = ""
8 set COUNT = 1
9for/F % I in (temp.txt) Do (
10 set filename = % I
11 echo! Filename!
12 set filename =! Filename :~ 18!
13 set tempname =! Filename!
14 call: stringlenth "! Filename! "Count
15 echo! Count!
16 if! Count! LSS 8 set tempname = traveled all over the United States! Filename!
17 echo! Filename!
18 echo! Tempname!
19 Ren "! Filename! ""! Tempname! "
20)
21
22 endlocal
23
24 exit
25
26: stringlenth
27
28 set thestring = % ~ 1
29if not defined thestring Goto: EOF
30 set return = 0
31: stringlenth_continue
32 set/a return + = 1
33 set thestring = % thestring :~ 0,-1%.
34if defined thestring goto stringlenth_continue
35if not "% 2" = "" set % 2 = % return %
36 Goto: EOF
37
38rem Delete temporary file del temp.txt/Q 1> NUL 2> nulpause
39
40rem summary use latency variables in a For Loop

Since I have downloaded videos from all over the United States, and subtitles have to be downloaded separately, the downloaded letters are different from the video file name, so I need to add four more words to travel across the United States,
I wrote the above batch to modify it, just to learn batch processing. There are 78 files in total.
Some code is useless, just for debugging
If you understand the syntax, it does not seem very troublesome.

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.