[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

【已解决】40元求文件搜索移动

本帖最后由 lxh623 于 2020-9-17 20:31 编辑

文件夹成千上万的png,是文字图像。
有个文本Unicode是,内容是:
U_0031DE
U_0031E2
U_0031E3
U_001B0A6
U_004E00
U_004E01
U_004E02
U_004E03
U_004E04
1、想创建子文件夹。
2、文件夹文件名类似于,U_004E00.png。当前文件夹列目录,得到文本a。
3、如果文本a的一行在文本Unicode里面搜索不到,就移动到子文件夹。
或许可以把结果写入文本,最后集中移动。
注意:最好整行搜索,完全一样。

谢谢!

回复 1# lxh623
  1. @echo off
  2. set "NewFolder=子文件夹"
  3. set "FileList=a.txt"
  4. set "FileCheck=Unicode.txt"
  5. if not exist "%NewFolder%" (
  6.     md "%NewFolder%"
  7. )
  8. dir /b *.png > "%FileList%"
  9. (for /f "" %%i in ('dir /b *.png') do (
  10.     echo,%%~ni
  11. ))>"%FileList%.tmp"
  12. for /f "delims=" %%i in ('type "%FileList%.tmp" ^| findstr /v /x /g:"%FileCheck%"') do (
  13.     move "%%i.png" "%NewFolder%"
  14. )
复制代码
1

评分人数

我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

  1. <# :
  2. cls
  3. @echo off
  4. cd /d "%~dp0"
  5. powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%~f0'"
  6. pause
  7. exit
  8. #>
  9. $self=get-item -liter $args[0];
  10. $path=$self.Directory.FullName;
  11. $newfolder=".\#NotFound";
  12. $txtfile=".\Unicode.txt";
  13. $ext=@(".png");
  14. $newfolder=$newfolder -replace '^\.',$path;$txtfile=$txtfile -replace '^\.',$path;
  15. if(-not (test-path -liter $txtfile)){Write-host ('"'+$txtfile+'" not found');exit;};
  16. if(-not (test-path -liter $newfolder)){[void](md $newfolder)};
  17. $dic=New-Object 'System.Collections.Generic.Dictionary[string,string]';
  18. $text=[IO.File]::ReadAllLines($txtfile,[Text.Encoding]::Default);
  19. for($i=0;$i -lt $text.count;$i++){
  20.     $line=$text[$i].trim();
  21.     if(-not $dic.ContainsKey($line)){$dic.add($line,'')};
  22. };
  23. $files=@(dir -liter $path|?{($ext -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
  24. for($i=0;$i -lt $files.length;$i++){
  25.     $base=$files[$i].BaseName;
  26.     if(-not $dic.ContainsKey($base)){
  27.         write-host $files[$i].Name;
  28.         move-item -liter $files[$i].FullName ($newfolder+'\'+$files[$i].Name);
  29.     };
  30. }
复制代码
1

评分人数

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

TOP

回复 2# Batcher
要是这个删除,就更完美了。
谢谢!
a.txt.tmp

TOP

回复 4# lxh623


    请自行在最后加一行 del 命令吧
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 5# Batcher
赞助了论坛。
谢谢!

TOP

返回列表