批处理复制到clipA的文件名和文件夹A中旧文件的路径中,但文件夹B中的名称相同 [英] batch to copy in clipbrd filenameandpath of the older file in folderA except the same name in folderB

查看:57
本文介绍了批处理复制到clipA的文件名和文件夹A中旧文件的路径中,但文件夹B中的名称相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件夹A中有C0001.mxf,C0002.mxf,C0003.mxf,C0004.mxf,C0005.mxf,C0006.mxf,C0007.mxf,C0008.mxf,C0009.mxf,C0010.mxf,C0011.mxf等等.

I have in folderA C0001.mxf, C0002.mxf, C0003.mxf, C0004.mxf, C0005.mxf, C0006.mxf, C0007.mxf, C0008.mxf, C0009.mxf, C0010.mxf, C0011.mxf ecc..

我暂时没有文件夹B

考虑到我已经在Windows/system32上安装了copy.exe(DOS应用程序) http://www.c3scripts.com/tutorials/msdos/clip.zip (例如,批量使用: echo%filepath%| clip 2&n; nul )

Consider I have installed on windows/system32 the copy.exe (dos application) http://www.c3scripts.com/tutorials/msdos/clip.zip ( e.g. use in batch: echo %filepath% | clip 2>nul )

我想建立一个执行此操作的批处理:在folderA中必须选择较旧的.mxf文件(最早的日期),然后必须将其完整的文件名和路径放入clipbrd中(例如c:\ folderA \ C0001.mxf)使用clip.exe应用程序,但是如果在folderB中选择的文件.mxf已经存在于folderB中(也如果它以C0001.avi或C0001.[任何扩展名]或只是不带扩展名的C0001存在),则该脚本必须复制进入clibrd,文件夹A中存在的下一个较旧的文件名和路径不在文件夹B中--->例如:如果文件夹B已经具有C0001和C0002和C0003 --->脚本必须放入clipbrd C:\ folderA \ C0004.mxf

I would like build a batch that do this: in folderA have to choose the older .mxf file (thay has the earliest date) then have to put in clipbrd its full filenameandpath (e.g. c:\folderA\C0001.mxf) using the clip.exe application, BUT if the file .mxf choosed in folderA is already present in folderB (also if it is present as C0001.avi or C0001.[anything extension] or simply C0001 without extension) then the script have to copy into the clibrd the filenameandpath of the next less old present in folderA that are not in folderB ---> EXAMPLE: if folderB already have C0001 and C0002 and C0003 ---> the script have to put in clipbrd C:\folderA\C0004.mxf

如果可能,批处理文件必须在开始时要求键入包含.mxf文件(文件夹A)的源文件

If possibile the batch file have to ask, at the beginnig, to type what is source containing .mxf files (folderA)

如果folderB包含文件夹A中包含的所有文件名(示例文件夹B具有C0001.avi,C0002.avi,C0003.avi,C0004.avi,C0005.avi和文件夹A具有C0001.mxf,C0002.mxf,C0003.mxf,C0004.mxf,C0005.mxf)----->脚本结束并没有执行任何操作

If folderB contains all the filename contained in folderA (example folderB have C0001.avi, C0002.avi, C0003.avi, C0004.avi, C0005.avi and folderA have C0001.mxf, C0002.mxf, C0003.mxf, C0004.mxf, C0005.mxf) -----> the script go to the end and do nothing

如果用户未键入folderA(.mxf文件的来源)并按键盘上的Enter键,则必须将folderA自动设置为当前文件夹

If the user don't type folderA (source of .mxf files) and press Enter on keyboard, the folderA have to be automatically set to the current folder

ps:我有一个脚本可以识别目录中的较旧文件,但目前无法对其进行修改:如果dir FolderA中的文件存在于文件夹B中,则将其的文件名和路径复制到clibrd中文件夹A中存在的下一个比文件夹B中存在的少-

ps: I had a script that can recognize the older file in a directory but at the moment I can not modify it to do that: if the files in dir FolderA are present in folder B then copy into the clibrd the filenameandpath of the next less old -present in folderA - than that found in folderB

set ext=.mxf
for /f "tokens=1,*" %%A in ("%*") do set folder=%%A %%B
if "%folder%"=="" set folder=%cd%
if not "%folder:~1,1%"==":" set folder=%cd%\%folder%
cd /d "%folder%"
for /f "delims=" %%G in ('dir *%ext% /b /o:-d /t:w') do set file=%%G
for %%H in ("%file%") do set filename=%%~nH
echo %filename% | clip 2>nul
if %errorlevel%==1 goto:EOF

推荐答案

更改 d:\ folderB 以适合您.

@echo off
:loop
set "d="
set "done="
set /p "d=Type source path (or press enter for current folder): "
if not defined d set "d=%cd%"
if not exist "%d%" echo Enter valid path - try again & goto :loop

cd /d "%d%"
for /f "delims=" %%a in ('dir *.mxf /b /od /a-d') do (
   if defined done goto :EOF
   if not exist "d:\folderB\%%~na.*" (
      echo %%~fa|clip >nul
      set done=1
   )
)

这篇关于批处理复制到clipA的文件名和文件夹A中旧文件的路径中,但文件夹B中的名称相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆