返回列表 发帖

有偿20.把文件夹内文件路径提取到表格。求大神帮个忙 非常感谢

一个文件夹内有许多产品文件夹,把产品文件夹内的图片(有多张)路径提取到表格,横着排走。求大神帮帮忙. 一个产品一行

test.bat
@echo off & cd /d "%~dp0"
setlocal enabledelayedexpansion
(
for /d %%i in (*) do (
pushd "%%i"
set "a=0"
for /f "delims=" %%a in ('dir /s /b *.png *.jpg 2^>nul') do (set /p="%%a,"<nul & set "a=1")
if "!a!"=="1" echo.
popd
)
) > "list.csv"
echo list.csv
pause&exitCOPY

TOP

回复 2# went


    有效果,但是只提取了20个文件夹,然后每个文件夹图片也没提取全

TOP

本帖最后由 zaqmlp 于 2022-4-9 23:51 编辑
<# :
cls&echo off&cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
pause
exit
#>
$outfile=".\all.csv";
$codes=@'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static class ExpDir
{
    [DllImport("Shlwapi.dll", CharSet=CharSet.Unicode)]
    public static extern int StrCmpLogicalW(string p1, string p2);
    public static string[] Sort(string[] f)
    {
        Array.Sort(f, StrCmpLogicalW);
        return f;
    }  
}
'@;
Add-Type -TypeDefinition $codes;
[System.Collections.ArrayList]$s=@();
$folders=@(dir -literal "."|?{$_ -is [System.IO.DirectoryInfo]});
for($i=0;$i -lt $folders.length;$i++){
    write-host $folders[$i].Name;
    $files=@(dir -literal $folders[$i].FullName|?{$_ -is [System.IO.FileInfo]}|%{$_.Name});
    if($files.length -ge 1){
        $arr=[ExpDir]::Sort($files);
        $line=@($arr|%{'"'+$folders[$i].FullName+'\'+$_+'"'}) -join "`t";
        [void]$s.add($line);
    }
}
[IO.File]::WriteAllLines($outfile, $s, [Text.Encoding]::Unicode);COPY
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 3# xiaohutok1


    如果文件夹里没有jpg和png文件就不会提取,你可以自己添加其它格式

TOP

回复 4# zaqmlp


    你好 提取出来排序乱了,能不能按照名称排序走。主图跑到后面去了

TOP

回复 6# xiaohutok1


    已修改
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 7# zaqmlp


    查收

TOP

返回列表