![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-23 13:28 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » Challenge - Batch modify file extensions and reverse file names simultaneously |
| Printable Version 3,056 / 12 |
| Floor1 lujice | Posted 2011-01-22 18:32 |
| 新手上路 Posts 13 Credits 12 | |
|
Challenge - Batch Modify File Extensions and Reverse File Names Simultaneously
The purposes of the batch processing are: 1. Batch modify the file extensions of specified types of files in the target folder (including all its subdirectories) to other specified extensions. 2. At the same time, batch reverse the file names of specified types of files in the target folder (including all its subdirectories). Supplementary Notes - 1. The batch processing must support: the user can enter the target folder (or drag and drop to get the path) directly in the running window of the batch processing, as well as the original extension and the new extension. 2. The path of the target folder may contain spaces. For example, the directory "C:\Documents and Settings\Administrator". 3. The path of the target folder may contain Chinese characters. For example, the directory "C:\Documents and Settings\Administrator\Desktop". 4. The path of the target folder may contain special characters. For example, characters "^" and "&". 5. Specific examples of renaming are: For example, "1234.original_extension" is renamed to "4321.new_extension". 6. In the case of double extensions: For example, "1234.jpg.original_extension" is renamed to "gpj.4321.new_extension". In short, only recognize the last extension as the real extension. All the previous ones are treated as the file name as a whole and reversed! 7. The batch processing must support renaming system or hidden attribute files. However, after renaming, the original attributes must be restored. [ Last edited by lujice on 2011-1-22 at 20:16 ] |
|
| Floor2 lujice | Posted 2011-01-22 18:35 |
| 新手上路 Posts 13 Credits 12 | |
|
The following code supports subdirectories, supports paths with special characters, and supports file names with special characters. Does not support reversing file names, does not support paths with spaces, and does not support file names with spaces.
[ Last edited by lujice on 2011-1-22 at 18:45 ] |
|
| Floor3 lujice | Posted 2011-01-22 19:05 |
| 新手上路 Posts 13 Credits 12 | |
|
It's so strange? Why does it support spaces and special characters again?
The following example has roughly the same syntax. But it just wants to support spaces and special characters! I can't figure it out...... [ Last edited by lujice on 2011-1-22 at 19:30 ] |
|
| Floor4 fsfss | Posted 2011-01-22 21:44 |
| 初级用户 Posts 20 Credits 22 | |
|
Batch-rename files with specified extension by reversing their filenames
|
|
| Floor5 lujice | Posted 2011-01-23 11:03 |
| 新手上路 Posts 13 Credits 12 | |
|
The following is the code from Boss "tmplinshi" of the "Batch Processing Home Forum" —
Tested! No bugs found so far! This tool is used to prohibit (restore) the execution of certain functions of the computer. For example, prohibit (restore) "My Computer - Right - Click - Manage", for example, prohibit (restore) "Folder Options", for example, prohibit (restore) all items in the Control Panel, prohibit (restore) Group Policy, prohibit (restore) Registry...... Hehe! Can others easily crack this prohibition method??? Thank you very much, Boss tmplinshi! Go back immediately, pick up the forum's tutorial, and slowly savor Boss tmplinshi's code...... Thank you again, Boss tmplinshi! [ Last edited by lujice on 2011-1-23 at 11:05 ] |
|
| Floor6 lujice | Posted 2011-01-23 11:14 |
| 新手上路 Posts 13 Credits 12 | |
|
Although I am a complete novice, only knowing the simplest commands. But, I dare to try...
In a couple of days, I will post a USB flash drive virus immunity batch processing. There is a bit of original DIY, which is to add a function to hide private files, and strengthen the ability to prevent deletion and renaming. Experts won't look at it, all are written with simple commands. Go back and scratch your head |
|
| Floor7 modestleaner | Posted 2011-01-23 20:36 |
| 初级用户 Posts 27 Credits 26 | |
|
Regarding the code in the original poster's and that LZ's post, I don't quite understand it. Could you please explain?
In the part where setting the file path is done: set lj= set /p lj= This can assign the path dragged in or input by the person using this batch script to LJ. But later when entering the file extension, it still uses set q= or something similar. Then, does it mean that the extension can also be dragged in? |
|
| Floor8 glodboy | Posted 2011-01-24 12:09 |
| 新手上路 Posts 11 Credits 10 | |
Originally posted by modestleaner at 2011-1-23 20:36: set lj= rem Set variable name set /p lj= rem Assign the obtained value to lj Personal understanding, please correct any errors. |
|
| Floor9 lujice | Posted 2011-01-24 15:43 |
| 新手上路 Posts 13 Credits 12 | |
Originally posted by modestleaner at 2011-1-23 20:36: First of all, I declare that I am also a very, very rookie, and I don't even understand the for statement very well. Let's learn together! @echo off (do not display executed commands) :hsz (this section's label number) echo.&echo.&echo Please drag and drop the directory for which you want to create the recycle bin into this window! echo. set /p mulu= (assign a value to variable %mulu%, supports hand input or drag and drop) echo.&echo Please hand-enter or paste the name of the recycle bin. echo.&echo The way to paste is - right-click in the running window of the batch script. echo.&echo If the name of the recycle bin contains spaces, special characters, and Chinese characters, echo.&echo then you need to add: English double quotes before and after the name - " echo. set /p minzi== (hand-enter to assign a value to variable %minzi%) md %mulu%\%minzi% (create a folder with the specified name in the specified directory) attrib +s +h %mulu%\%minzi% (change its attributes to system and hidden) (echo echo CLSID={645FF040-5081-101B-9F08-00AA002F954E})>%mulu%\%minzi%\desktop.ini (write the characters in the parentheses to the "desktop.ini" file under the target folder) attrib +s +h %mulu%\%minzi%\desktop.ini (change the attribute of the "desktop.ini" file to system and hidden) echo.&echo The recycle bin has been successfully created! echo.&echo Open it and take a look! echo. pause (pause) start "" %mulu% (open the directory where the recycle bin is created) goto (label number of the upper menu) [ Last edited by lujice on 2011-1-24 at 15:47 ] |
|
| Floor10 modestleaner | Posted 2011-01-24 18:06 |
| 初级用户 Posts 27 Credits 26 | |
Originally posted by glodboy at 2011-1-24 12:09: First of all, thank you to the above-mentioned friends for their answers, but I'm afraid the brother here has an incorrect understanding ![]() The function of /p is to allow the variable value to be set as a line of input from the user. I understand the part about creating a recycle bin in the specified folder, but I still don't understand that sentence. |
|
| Floor11 lujice | Posted 2011-01-24 19:47 |
| 新手上路 Posts 13 Credits 12 | |
Originally posted by modestleaner at 2011-1-23 20:36: The file extension cannot be dragged in. After dragging a file in, the full path including the file name is displayed. Unless you use the backspace key to delete the extra characters and only leave the file extension. But what's the difference between this and typing in the file extension manually? [ Last edited by lujice on 2011-1-24 at 19:49 ] |
|
| Floor12 lujice | Posted 2011-01-24 19:48 |
| 新手上路 Posts 13 Credits 12 | |
Originally posted by modestleaner at 2011-1-23 20:36: The file extension cannot be dragged in. After dragging a file in, the full path including the file name is displayed. Unless you use the backspace key to delete the excess characters and only leave the file extension. But what's the difference between doing this and typing in the file extension manually? |
|
| Floor13 modestleaner | Posted 2011-01-25 00:48 |
| 初级用户 Posts 27 Credits 26 | |
Originally posted by lujice at 2011-1-24 19:48: Hmm, I know that the file extension can't be dragged in. What I mean is that then is that sentence redundant? Since the extension can't be dragged in and can only be entered manually. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |