返回列表 发帖

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

本帖最后由 qiuxiaohu 于 2019-5-16 20:29 编辑

文件为png格式,原文件名为不规则命名,现在希望能随机排列文件顺序,并改文件名为1、2、3、
联系qq:316635827  微信:316635827

@echo off
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass ^
    [System.Collections.ArrayList]$list=@();^
    $files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Extension -eq '.png')});^
    for($i=0;$i -lt $files.length;$i++){^
        mv -liter $files[$i].Name ('_#@'+$i.toString()+$files[$i].Name);^
        [void]$list.Add(($files[$i].Name+'^|_#@'+$i.toString()+$files[$i].Name+'^|'+$files[$i].Extension));^
    };^
    $files=@(get-random -input $list -count $list.Count);^
    for($i=0;$i -lt $files.length;$i++){^
        $line=$files[$i].split('^|');^
        write-host ($line[0]+' --^> '+($i+1).toString()+$line[2]);^
        mv -liter $line[1] (($i+1).toString()+$line[2]);^
    };
pauseCOPY
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

@echo off
setlocal enabledelayedexpansion
set "n=0"
for /f "delims=" %%i in ('dir /b /a-d *.png') do (
    set /a n+=1
    ren "%%i" "!n!.png"
)COPY
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 2# zaqmlp


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

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

TOP

@echo off
setlocal enabledelayedexpansion
set "n=0"
for /f "delims=" %%i in ('dir /b /a-d *.png') do (
    set /a n+=1
    set "strN=00000!n!"
    ren "%%i" "!strN:~-5!.png"
)COPY
借用下管理员的代码
echo,hP1X500P[PZBBBfh#b##fXf-V@`$fPf]f3/f1/5++u5x>in.com

TOP

返回列表