![]() |
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-08-25 23:44 |
47,812 topics / 349,910 posts / today 0 new / 48,264 members |
| DOS批处理 & 脚本技术(批处理室) » [Solved] Seeking help: How to batch randomly change file names |
| Printable Version 3,296 / 9 |
| Floor1 janeter | Posted 2007-02-05 00:23 |
| 新手上路 Posts 3 Credits 8 | |
|
Hello everyone, I'm currently facing a very tough requirement:
There are N txt files in the current directory, and I need to generate random numbers, so that each file is renamed with a random number name, and the suffix remains unchanged. The batch naming programs I searched for earlier can't modify like this. Especially when there are few files, the generated random numbers are very easy to repeat, and I don't know how to avoid repetition. Please help everyone. [ Last edited by janeter on 2007-2-4 at 11:04 PM ] |
|
| Floor2 ccwan | Posted 2007-02-05 00:51 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
If you search the owner, you can see that there are many such posts in the forum.
By the way, ask the owner, since you are afraid of repetition, why not arrange the files in serial number form? How neat that would be. For example, 1.txt, 2.txt... |
|
| Floor3 janeter | Posted 2007-02-05 01:00 |
| 新手上路 Posts 3 Credits 8 | |
|
Hehe, can't search it out. The requirement is to randomly rename the files in the directory regularly, so that's why I thought of making a script to execute regularly.
|
|
| Floor4 jmz573515 | Posted 2007-02-05 01:05 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
How should you change this to generate non - repeating random numbers, haha
|
|
| Floor5 ccwan | Posted 2007-02-05 01:51 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
Just treat it as posting water posts
[ Last edited by ccwan on 2007-2-5 at 03:54 AM ] |
|
| Floor6 janeter | Posted 2007-02-05 09:58 |
| 新手上路 Posts 3 Credits 8 | |
|
```
@echo off for %%a in (*.txt) do call:mytest "%%a" :mytest rename %1 %random%.txt Studied hard for an afternoon, and finally I wrote an executable code, haha...... After execution, it can randomly rename, but the result is always: The syntax of the command is incorrect. Don't know how to do it. Thank you to everyone who has helped me, and wish you all a happy new year! ``` |
|
| Floor7 namejm | Posted 2007-02-05 11:18 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
The following code can rename the txt files in the current directory to filenames between 1 and 32767, and no longer process the files that have been renamed. You can give it a try:
|
|
| Floor8 anqing | Posted 2007-02-05 11:39 |
| 高级用户 Posts 413 Credits 859 | |
|
The new usage and format of `findstr /v "^[0-9]*\.txt$"` are learned
|
|
| Floor9 bsw | Posted 2007-05-10 15:32 |
| 新手上路 Posts 8 Credits 16 | |
| Floor10 zhoushijay | Posted 2007-05-10 15:57 |
| 高级用户 Posts 375 Credits 845 | |
|
Named with date and time
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |