找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 20183|回复: 4

支付宝或微信10元;批处理随机调整文件顺序,并按顺序命名为1、2、3……,

  [复制链接]
发表于 2019-5-16 20:28:31 | 显示全部楼层 |阅读模式
本帖最后由 qiuxiaohu 于 2019-5-16 20:29 编辑

文件为png格式,原文件名为不规则命名,现在希望能随机排列文件顺序,并改文件名为1、2、3、
联系qq:316635827  微信:316635827
发表于 2019-5-16 20:45:03 | 显示全部楼层
  1. @echo off
  2. cd /d "%~dp0"
  3. powershell -NoProfile -ExecutionPolicy bypass ^
  4.     [System.Collections.ArrayList]$list=@();^
  5.     $files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Extension -eq '.png')});^
  6.     for($i=0;$i -lt $files.length;$i++){^
  7.         mv -liter $files[$i].Name ('_#@'+$i.toString()+$files[$i].Name);^
  8.         [void]$list.Add(($files[$i].Name+'^|_#@'+$i.toString()+$files[$i].Name+'^|'+$files[$i].Extension));^
  9.     };^
  10.     $files=@(get-random -input $list -count $list.Count);^
  11.     for($i=0;$i -lt $files.length;$i++){^
  12.         $line=$files[$i].split('^|');^
  13.         write-host ($line[0]+' --^> '+($i+1).toString()+$line[2]);^
  14.         mv -liter $line[1] (($i+1).toString()+$line[2]);^
  15.     };
  16. pause
复制代码
发表于 2019-5-16 21:13:31 | 显示全部楼层
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set "n=0"
  4. for /f "delims=" %%i in ('dir /b /a-d *.png') do (
  5.     set /a n+=1
  6.     ren "%%i" "!n!.png"
  7. )
复制代码
 楼主| 发表于 2019-5-17 09:17:27 | 显示全部楼层
回复 2# zaqmlp


    你的批处理,老是提醒风险,功能倒是满足了我的需求。麻烦你添加我的微信,我好给你发红包。最好你能再进一步处理一下,不要老是提示风险。

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
发表于 2019-5-18 15:27:59 | 显示全部楼层
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set "n=0"
  4. for /f "delims=" %%i in ('dir /b /a-d *.png') do (
  5.     set /a n+=1
  6.     set "strN=00000!n!"
  7.     ren "%%i" "!strN:~-5!.png"
  8. )
复制代码
借用下管理员的代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 04:11 , Processed in 0.015919 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表