从文件创建文件夹,初始文件复制到文件夹并添加preFIX [英] Creating folder from file, copy initial file into folder and add prefix
本文介绍了从文件创建文件夹,初始文件复制到文件夹并添加preFIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个文件夹应当与文件名的洪流完成后创建。文件应复制(不移动),并应增加一个preFIX。
这是我的实际的.bat
A folder should be created with file names after a torrent is finished. The files should be copied (not moved) and a prefix should be added. This is my actual .bat
for /F "Tokens=*" %%i in ('Dir /B *.mp4') do md "%%~ni"|copy "%%i" "%%~ni"
这工作到目前为止,但我没能拿到preFIX增加。这preFX应该被添加到该文件夹中新创建的文件。
This works so far but I was not able to get a prefix added. That prefx should be added to the newly created file in the folder.
一种进度条,如YY MB的XX MB为AA MB / s的速度将是不错,但不是必需的。
A kind of progress bar like "xx MB of yy MB at aa MB/s Speed" would be nice but not essential.
推荐答案
试试这个
for /f "tokens=*" %%A in ('dir /b *.mp4') do (
md "%%~nA"
copy "%%~fA" "%%~nA\prefix_%%~nxA"
)
这将复制 abc.mp4 - > ABC \\ prefix_abc.mp4
要输出进度
@echo off
setlocal
set _cmd='dir /b *.mp4'
set _prefix=movie_
set _progress_width=40
set _progress_char1=+
set _progress_char2=-
set _progress_char3=+
set _progress_fill=*
set _count=0
set _i=1
rem Counting files
for /f "tokens=*" %%A in (%_cmd%) do set /a "_count+=1"
call :print_scale
for /f "tokens=*" %%A in (%_cmd%) do (
md "%%~nA" >nul 2>&1
copy "%%~fA" "%%~nA\%_prefix%%%~nxA" >nul 2>&1
rem Output progress
call :progress _i _count
call title Completed [%%_i%%/%%_count%%]
set /a "_i+=1"
)
endlocal
exit /b 0
:print_scale
set /a "_width=_progress_width-2"
set "_fill="
for /l %%B in (1,1,%_width%) do call set "_fill=%%_fill%%%%_progress_char2%%"
echo %_progress_char1%%_fill%%_progress_char3%
exit /b 0
:progress
call set _current=%%%1%%
call set _total=%%%2%%
set /a "_width=_progress_width"
set /a "_pos=_width*_current/_total-_width*(_current-1)/_total"
for /l %%B in (1,1,%_pos%) do echo|set /p _z=%_progress_fill%
exit /b 0
这就像将输出的进展
+--------------------------------------+
*************
这篇关于从文件创建文件夹,初始文件复制到文件夹并添加preFIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文