Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the batch processing of modifying file name

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to modify the file name of the batch processing, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Example 1

@ echo off & setlocal enabledelayedexpansion echo-= = file name substitution (excluding _ v2 and _ V3 from the file name) =-echo. Echo. Set / p folder= Please enter a path: for / r% folder%% I in (*) do (set file=%%i set fileholdings filefor v2! Set fileholders, filehols, v3 players! If I neq! file! (move "% I"! file!") echo. Echo. The replacement of all filenames for echo is complete. Echo exits by pressing any key. Pause > nul

Instance 2 batch replace and modify file name

When you have a lot of similar files, the file names can be regular but somewhat irregular. You can try this batch.

@ echo offecho.&echo.title batch replace some strings in the file name & color 3fecho Note:echo this batch can batch replace the same characters echo.&echo.&echo.&echo.&echo.&echo.echo.&set / p strtemp3= of all file names under the folder where this file is located. Please enter the file type to be replaced: echo.&set / p strtemp1= Please enter the string to be replaced (replaceable spaces): echo. & set / p strtemp2= Please enter the replaced string (delete and enter directly): setlocal enabledelayedexpansionfor / f "delims="% an in ('dir / a / b *.% strtemp3%') do (set nobird=%%aren "% ~ a"! Nobirdsetlocal enabledelayedexpansionfor% strtemp1% strtemp1% strtemp2%! ") echo.&echo.&echo.&echo.&echo Done! Pause

Batch renamed to numerically added implementation code

1. Select the file to be renamed collectively, right-click and rename to a non-numeric name

two。 Save this command as bat and put it in the directory to be renamed, change the name to demo.bat (or change it to something else, and the code will be changed)

@ echo offsetlocal enabledelayedexpansionfor% x in (*) do (if not "% x" = = "demo.bat" (set / a sum+=1 rename "% x"! summer.txt ")) echo batch renaming completed! Pause

3. Change different suffix names according to your own needs

Batch command to achieve file specification renaming

Usually less use of batch commands, through online learning to achieve this function, share with friends in need.

The names of all files (excluding subfolders) under the specified suffix (such as this example JPG) under the folder where the batch is located are canonical file names.

Echo off&setlocal EnableDelayedExpansion set a=0for / f "delims="% I in ('dir / b * .jpg') do (if not "% ~ ni" = = "% ~ N0" (if! a! LSS 10 (ren "% I"sample0000room.jpg") else if! a! LSS 100 (ren "% I"sample000roomaroom.jpg") else if! a! LSS 1000 (ren "% I"sample00roomaxi.jpg") else if! a! LSS 10000 (ren "% I"sample0sample0roomaroom.jpg") else (ren "% I"sampleroomaroom.jpg")) Thank you for reading this article carefully. I hope the article "how to change the name of a file" shared by the editor will be helpful to you. At the same time, I hope you can support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report