简体   繁体   English

基于多个文件名批量创建多个文件夹,并将多个相关文件移动到创建的文件夹中

[英]Batch Create Several Folders Based on Multiple Filenames, and Move Multiple Related Files to The Created Folders

Every week, one of my co-workers has had to go through a folder with hundreds of demuxed video and audio files, rename each one individually for a specific city TV station and then sort them into folders based on the name of the city.每周,我的一位同事都不得不通过一个包含数百个解复用视频和音频文件的文件夹来 go,为特定城市电视台单独重命名每个文件,然后根据城市名称将它们分类到文件夹中。 I've created a.bat file to rename them all for him, and now I'd like to create a.bat file that creates new directories based on the filenames, and places the corresponding files into the new folders.我已经创建了一个 .bat 文件来为他重命名它们,现在我想创建一个 .bat 文件,该文件根据文件名创建新目录,并将相应的文件放入新文件夹中。 I copied a few of the files to test with.我复制了一些文件进行测试。

在此处输入图像描述

So the end result will be a "Houston" folder with all it's corresponding files, a "Compton" folder with it's files, a "Moline" folder, etc, etc... for every city, up to around 200 cities, and we're only getting more.所以最终的结果将是一个包含所有相应文件的“Houston”文件夹、一个包含文件的“Compton”文件夹、一个“Moline”文件夹等等……每个城市,最多大约200 个城市,我们'只会越来越多。

He's currently searching "Houston", cutting all the files that come up, creating a new folder manually, naming it "Houston" and pasting all the files into his new folder.他目前正在搜索“Houston”,剪切所有出现的文件,手动创建一个新文件夹,将其命名为“Houston”并将所有文件粘贴到他的新文件夹中。 FOR EVERY CITY.对于每个城市。 200 TIMES. 200 次。 And it takes hours.这需要几个小时。

The files are ALWAYS named with this system: X### Random City, ST文件总是用这个系统命名:X### Random City, ST

With my little wee programming knowledge, I'm supposing that the script could detect all the characters after the first space, and before the comma, copy those characters (Random City), create a new folder, name it the copied characters (Random City) then move any files containing "Random City" in their filename into the newly created folder.凭借我的一点编程知识,我假设脚本可以检测到第一个空格之后和逗号之前的所有字符,复制这些字符(随机城市),创建一个新文件夹,将其命名为复制的字符(随机城市) 然后将文件名中包含“随机城市”的所有文件移动到新创建的文件夹中。 The end result would be as such, just with a lot more folders.最终结果就是这样,只是有更多的文件夹。

在此处输入图像描述

Is there anyone more advanced than me who could explain the best way to to this?有没有比我更先进的人可以解释最好的方法?

I apologize in advance if I'm in the wrong place or not savvy enough.如果我在错误的地方或不够精明,我会提前道歉。 Cheers!干杯!

UPDATE: I messed around, learned about tokens and delimiters, variables etc. Here is what I have which works amazingly, except I'm not sure how to remove the comma at the end of the city name.更新:我搞砸了,了解了标记和分隔符、变量等。这是我所拥有的东西,效果非常好,除了我不确定如何删除城市名称末尾的逗号。 I'm using space as the delimiter, which makes the text chunks the tokens if I understand correctly, including my comma, using tokens=2.我使用空格作为分隔符,如果我理解正确,这会使文本块成为标记,包括我的逗号,使用标记=2。 Another problem that arises;出现的另一个问题; Say there's a city with two text chunks (tokens) eg.假设有一个城市有两个文本块(令牌),例如。 San Fransisco, Baton Rouge.旧金山,巴吞鲁日。 How could I grab both of them, using the comma as my stopping point?我怎么能抓住他们两个,用逗号作为我的停止点? My code is below.我的代码如下。

@echo off
setlocal enabledelayedexpansion
for %%A in (*.m2v *.mpa) do (
   echo file found  %%A
   for /f "delims=" %%B in ("%%A") do set fname=%%~nB
   for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /f "tokens=2* delims= " %%D in ("!fname!") do set folname=%%D
   echo folder name !folname!
   if not exist "!folname!" (
      echo Folder !folname! doesn't exist, creating
      md "!folname!"
   ) else (
      echo Folder !folname! exists
   )
   echo Moving file %%A to folder !folname!
   move "%%A" "!folname!"
   )
echo Finished

pause

UPDATE 2: I found a meh workaround to get rid of the comma, by adding it as a delimiter, but I'm still trying to wrap my head around the 2 word cities.更新 2:我找到了一种解决方法来摆脱逗号,通过将它添加为分隔符,但我仍然试图围绕 2 个单词的城市。 My Baton Rouge and San Fransisco folders are being named respectively, "Baton" and "San".我的 Baton Rouge 和 San Fransisco 文件夹分别被命名为“Baton”和“San”。 Here is my code so far, I'll update if I find a better way.到目前为止,这是我的代码,如果我找到更好的方法,我会更新。

setlocal enabledelayedexpansion
for %%A in (*.m2v *.mpa) do (
   echo file found  %%A
   for /f "delims=" %%B in ("%%A") do set fname=%%~nB
   for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
   for /f "delims=," %%B in ("%%A") do set fname=%%~nB
   for /f "tokens=2* delims= " %%D in ("!fname!") do set folname=%%D
   echo folder name !folname!
   if not exist "!folname!" (
      echo Folder !folname! doesn't exist, creating
      md "!folname!"
   ) else (
      echo Folder !folname! exists
   )
   echo Moving file %%A to folder !folname!
   move "%%A" "!folname!"
   )
echo Finished

pause

UPDATE 3更新 3

Here is my code which worked.这是我的有效代码。 However, if the number of characters in your filename prefixes/suffixes changes, it will screw things up and you'll have to edit code.但是,如果文件名前缀/后缀中的字符数发生变化,就会搞砸,您将不得不编辑代码。

@ECHO OFF
SETLOCAL enabledelayedexpansion
FOR %%A in (*.m2v *.mpa) do (
   ECHO file found  %%A
   FOR /F "delims=" %%B in ("%%A") do set fname=%%~nB
   SET folname=!fname:~5,-4!
   ECHO folder name !folname!
   if not exist "!folname!" (
      ECHO Folder !folname! doesn't exist, creating
      MD "!folname!"
   ) else (
      ECHO Folder !folname! exists
   )
   ECHO Moving file %%A to folder !folname!
   MOVE "%%A" "!folname!"
   )
ECHO Finished

PAUSE

Using the SET folname=:fname,~5,-4!使用SET folname=:fname,~5,-4! allows me to trim the M373 prefix, 5 characters in, and the, TX suffix, 4 characters in, removing the comma and salvaging the city name, regardless of how long it is, or how many words it is (eg. West Palm Beach, FL).允许我修剪 M373 前缀、5 个字符和 TX 后缀、4 个字符,删除逗号并挽救城市名称,无论它有多长或有多少单词(例如西棕榈滩,佛罗里达州)。 Antares mentioned this solution in his answer which worked like a charm. Antares 在他的回答中提到了这个解决方案,它就像一个魅力。

BUT IT ALSO MADE ME THINK但它也让我思考

If the number of characters in the prefix changes, which is likely, I'll either have to edit the batch file every time, or create a specific batch file for each circumstance.如果前缀中的字符数发生变化(这很可能),我要么必须每次都编辑批处理文件,要么为每种情况创建一个特定的批处理文件。 Not terrible, but not great either.不可怕,但也不是很好。 So I went with Michael Heath's answer which works flawlessly.所以我选择了迈克尔希思的答案,它完美无缺。 I'm not smart enough yet to know exactly why, but I'm gonna dissect it and find out.我还不够聪明,无法确切知道原因,但我会剖析它并找出答案。 I have a lot of learning to do.我有很多学习要做。 Thanks, everyone!感谢大家! 前 后

@echo off
setlocal

rem A=Fullpath, B=Name before comma, C=B prefix, D=B without prefix.
for /f "delims=" %%A in ('dir /b *.m2v *.mpa') do (
    for /f "delims=," %%B in ("%%~nA") do (
        for /f "tokens=1,*" %%C in ("%%~B") do (

            if not exist "%%~D\" (
                echo Folder "%%~D" doesn't exist, creating
                md "%%~D"
            )

            if exist "%%~D\" (
                echo Moving file "%%~A" to folder "%%~D\"
                move /y "%%~A" "%%~D\"
            ) else echo Folder "%%~D\" doesn't exist
        )
    )
)

echo Finished
pause

3 for loops to get the tokens needed. 3 for循环来获取所需的令牌。

  • 1st will get the fullpath.第一个将获得完整路径。
  • 2nd to get the name before the comma.第二个获取逗号前的名称。
  • 3rd to get the name without the prefix.第三获得没有前缀的名称。

In the nested for loops check if folder exists, create it if not.在嵌套for循环中检查文件夹是否存在,如果不存在则创建它。 Then if folder exists, move file inside.然后如果文件夹存在,将文件移到里面。

I can give you some hints.我可以给你一些提示。 If you have a more specific problem case, feel free to update your question again.如果您有更具体的问题案例,请随时再次更新您的问题。

You can cut the last X characters of a String like this: %variablename:~0,-X%您可以像这样剪切字符串的最后 X 个字符: %variablename:~0,-X%

If you know the variables with the city parts, eg %%D and %%E or something, you can concatenate them again like this md "%%D %%E" .如果你知道城市部分的变量,例如 %%D 和 %%E 什么的,你可以像这样再次连接它们md "%%D %%E" However, this works just for a fixed number of tokens, like the two here.但是,这仅适用于固定数量的令牌,就像这里的两个一样。
You can store this concatenations in an own variable, if you need the result outside of your for-loop.如果您需要 for 循环之外的结果,您可以将此连接存储在自己的变量中。 Use set myVariable=%%D %%E for example, and show it with %myVariable% or !myVariable!例如,使用set myVariable=%%D %%E ,并使用%myVariable%!myVariable! (when delayed expansion is needed), for example md "%myVariable%" . (当需要延迟扩展时),例如md "%myVariable%"

A nifty workaround: if there are only a small number of "special cities" to take into consideration, then you could just add some rename commands at the end of your script, like rename San "San Francisco" , rename Baton "Baton Rouge" , etc. Will not work well, if there are more "San" cities (eg "San Bernadino"), because this cannot be distinguished anymore.一个很好的解决方法:如果只考虑少数“特殊城市”,那么您可以在脚本末尾添加一些重命名命令,例如rename San "San Francisco"rename Baton "Baton Rouge"等。如果有更多的“San”城市(例如“San Bernadino”),将无法正常工作,因为这无法再区分了。 But in this case, the copying into separate folders would already fail as well.但在这种情况下,复制到单独的文件夹也已经失败。

In your script you make a check for an existing folder.在您的脚本中,您检查现有文件夹。 I think you can omit that.我认为你可以省略它。 md or mkdir either create that directory or do nothing if it exists. mdmkdir要么创建该目录,要么不执行任何操作(如果存在)。 Well, they do print a message to the console, which can be ignored.好吧,他们确实向控制台打印了一条消息,可以忽略。 If you do not want to see them, redirect the error message stream to nul like this md myFolder 2>nul .如果您不想看到它们,请将错误消息 stream 重定向到nul ,例如md myFolder 2>nul This will swallow any error messages, but it is unlikely that you get any other error message than that in your scenario.这将吞没任何错误消息,但您不太可能收到任何其他错误消息,而不是您的场景中的错误消息。

You could simplify your approach like this: I reckon your file renaming works well.您可以像这样简化您的方法:我认为您的文件重命名效果很好。 Your "copy" script could be just a list of commands which are stated explicitly (and also could be edited fairly quickly if new cities are to be considered).您的“复制”脚本可能只是一个明确说明的命令列表(如果要考虑新城市,也可以相当快地编辑)。
Set the batch file up like this with entries for each city:像这样使用每个城市的条目设置批处理文件:

@echo off
mkdir "Moline"
copy "*Moline*.*" "Moline"

mkdir "San Francisco"
copy "*San Francisco*.*" "San Francisco"

...

echo done.

Side effect is, that the folders for each city will be created, not just those where files are copied into.副作用是,将创建每个城市的文件夹,而不仅仅是文件复制到的文件夹。 May be it suits your needs anyhow.无论如何,它可能适合您的需求。

Also, I would like to give you pointers to sources of help/documentation:另外,我想给你一些帮助/文档来源的指针:

On the command line you can get extensive help by executing the commands used in your batch file and appending /?在命令行上,您可以通过执行批处理文件中使用的命令并附加/?来获得广泛的帮助。 . . For example set /?例如set /? gives you a lot of useful things you can do with variables/String manipulations.给你很多有用的东西,你可以用变量/字符串操作来做。
Try: for /?尝试: for /? , if /? , if /? (regarding errorlevel for example), maybe call /? (例如关于错误errorlevel ),也许call /? , goto /? , goto /? , and others. , 和别的。

A very good source for all the command line commands is https://www.ss64.com .所有命令行命令的一个很好的来源是https://www.ss64.com This site provides extensive help even for PowerShell and Linux Bash and others.该站点甚至为 PowerShell 和 Linux Bash 等提供广泛的帮助。 Relevant to you in this case would be CMD , direct link: https://ss64.com/nt/在这种情况下与您相关的是CMD ,直接链接: https://ss64.com/nt/

Edit/Update:编辑/更新:
Check out symbol replacement on the set command to build something like检查set命令上的符号替换以构建类似的东西

if "%myVariable:~0,1%" == "M" (set myvariable=%myvariable:~1%)

The first part "cuts" the first character and checks, if it is an M and if so, it keeps everything except the first character.第一部分“剪切”第一个字符并检查它是否是 M,如果是,则保留除第一个字符之外的所有内容。 With this you could make your filenames even out to process them inside your batch file.有了这个,你可以使你的文件名均匀,以便在你的批处理文件中处理它们。
You can also "remove" a letter or substring with %myVariable:, TX=% which would replace any ", TX" occurance with "nothing" for example.您还可以使用%myVariable:, TX=% "删除" 一个字母或 substring,例如,这将用 "nothing" 替换任何 ", TX" 出现。

Oh, this could also help to remove any spaces in the filename.哦,这也有助于删除文件名中的任何空格。 Then you could extract the "SanFrancisco" without a spaces problem;) The folder name would be without space though.然后你可以提取没有空格问题的“SanFrancisco”;)虽然文件夹名称没有空格。 This could be resolved with further rename commands at the end.这可以在最后通过进一步的rename命令来解决。

Here is my code which worked.这是我的有效代码。 However, if the number of characters in your filename prefixes/suffixes changes, it will screw things up and you'll have to edit code.但是,如果文件名前缀/后缀中的字符数发生变化,就会搞砸,您将不得不编辑代码。

@ECHO OFF
SETLOCAL enabledelayedexpansion
FOR %%A in (*.m2v *.mpa) do (
   ECHO file found  %%A
   FOR /F "delims=" %%B in ("%%A") do set fname=%%~nB
   SET folname=!fname:~5,-4!
   ECHO folder name !folname!
   if not exist "!folname!" (
      ECHO Folder !folname! doesn't exist, creating
      MD "!folname!"
   ) else (
      ECHO Folder !folname! exists
   )
   ECHO Moving file %%A to folder !folname!
   MOVE "%%A" "!folname!"
   )
ECHO Finished

PAUSE

Using the SET folname=:fname,~5,-4!使用SET folname=:fname,~5,-4! allows me to trim the M373 prefix, 5 characters in, and the, TX suffix, 4 characters in, removing the comma and salvaging the city name, regardless of how long it is, or how many words it is (eg. West Palm Beach, FL).允许我修剪 M373 前缀、5 个字符和 TX 后缀、4 个字符,删除逗号并挽救城市名称,无论它有多长或有多少单词(例如西棕榈滩,佛罗里达州)。 Antares mentioned this solution in his answer which worked like a charm. Antares 在他的回答中提到了这个解决方案,它就像一个魅力。

BUT IT ALSO MADE ME THINK但它也让我思考

If the number of characters in the prefix changes, which is likely, I'll either have to edit the batch file every time, or create a specific batch file for each circumstance.如果前缀中的字符数发生变化(这很可能),我要么必须每次都编辑批处理文件,要么为每种情况创建一个特定的批处理文件。 Not terrible, but not great either.不可怕,但也不是很好。 So I went with Michael Heath's answer which works flawlessly.所以我选择了迈克尔希思的答案,它完美无缺。 I'm not smart enough yet to know exactly why, but I'm gonna dissect it and find out.我还不够聪明,无法确切知道原因,但我会剖析它并找出答案。 I have a lot of learning to do.我有很多学习要做。 Thanks, everyone!感谢大家! Before Image After Image前图像后图像

Here's an alternative method, just for the sake of variety :这是一种替代方法,只是为了多样化

@Echo Off
SetLocal DisableDelayedExpansion

Set "SourceDir=.\Batch Rename\BACKUP"

If Exist "%SourceDir%\" For /F "EOL=|Delims=" %%G In (
    '%__AppDir__%where.exe "%SourceDir%":"*, ??.m??" 2^>NUL'
)Do (Set "FileBaseName=%%~nG"&SetLocal EnableDelayedExpansion
    For /F "EOL=|Delims=," %%H In ("!FileBaseName:* =!")Do (EndLocal
    %__AppDir__%Robocopy.exe "%%~dpG." "%%~dpG%%H" "%%~nxG" /Mov>NUL))

This method filters your files with the where command.此方法使用where命令过滤您的文件。 It selects for moving, only file names which end with a comma, followed by a space, followed by two letters, followed by a three letter extension beginning with the character m .它只选择以逗号结尾的文件名,后跟空格,后跟两个字母,后跟以字符m开头的三个字母扩展名。 It moves the files, automatically creating the destination directories if they do not exist, using the robocopy command.它使用robocopy命令移动文件,如果它们不存在,则自动创建目标目录。 It uses only two for loops, the second of which, isolates the string between the first space and the next comma.它只使用两个for循环,第二个循环将第一个空格和下一个逗号之间的字符串隔离开来。

I have made it so that the script can be located anywhere, not necessarily in the directory with the files.我已经这样做了,以便脚本可以位于任何地方,不一定在文件所在的目录中。 This location is set on line 3 of the script, If you wish to modify it, please ensure that your location remains between the = and the closing double-quote, " , and does not end with a trailing back-slash, \ . It is currently set to a relative directory, (based upon that visible in your screen-shot) , but you could obviously use an absolute path too, eg Set "SourceDir=C:\Users\UserName\Videos" . If you wish to keep the script in the same directory as the files to be moved, change it to read Set "SourceDir=." and just double-click it to run.此位置在脚本的第3行设置,如果您想修改它,请确保您的位置保持在=和右双引号"之间,并且不以尾部反斜杠\结尾。它当前设置为相对目录, (基于屏幕截图中可见的目录) ,但您显然也可以使用绝对路径,例如Set "SourceDir=C:\Users\UserName\Videos" 。如果您希望保留将脚本与要移动的文件放在同一目录中,将其更改为Set "SourceDir=."并双击运行。

When I had to develop a script for the task at hand I would probably implement a few safety features in order to not move wrong files.当我不得不为手头的任务开发脚本时,我可能会实现一些安全功能,以免移动错误的文件。 Your sample data show pairs of .m2v and .mpa files, but I would likely not consider that as granted.您的示例数据显示成对的.m2v.mpa文件,但我可能不会认为这是理所当然的。 Also would I not rely on a fixed-length prefix.我也不会依赖固定长度的前缀。 Finally, I would perhaps also account for lit 's comment .最后,我也许还要考虑lit评论

So here is my attempt (see all the explanatory rem -remarks in the code):所以这是我的尝试(请参阅代码中的所有解释性rem -remarks):

@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem // Define constants here:
set "_ROOT=%~dp0."         & rem // (root directory containing the files to be processed)
set "_MASK=M??? *, ??.m2v" & rem // (mask to find the files to be processed)
set _EXTS=".m2v" ".mpa"    & rem /* (list of extensions that must all be present;
                             rem     extensions are not checked if this is empty;
                             rem     `_MASK` should then be changed to end with `.m*`) */
set "_FILT=^M[0-9][0-9][0-9] [^,][^,]*, [A-Z][A-Z]\.[^\.][^\.]*$"
                             rem // (additional filter to find files; deactivate by `.*`)
set "_SEPS=,"              & rem /* (defines (a) separator character(s) to derive the
                             rem     sub-directory; leave it blank to use full name) */

rem // Change into the root directory:
pushd "%_ROOT%" && (
    rem /* Loop through all files matching the mask as well as the additional filter;
    rem    if the post-filtering is not needed, remove `^|` and everything behind: */
    for /F "delims= eol=|" %%F in ('
        dir /B /A:-D-H-S "%_MASK%" ^| findstr /I /R /C:"%_FILT%"
    ') do (
        rem // Get the portion in front of the `,` of the file name:
        for /F "delims=%_SEPS% eol=|" %%G in ("%%~nF") do (
            rem // Split that portion at the first space to get the city name:
            for /F "tokens=1* eol=|" %%H in ("%%G") do (
                rem // initialise flag that indicates whether to move the current file:
                set "FLAG=#"
                rem // Skip the following checks if there are no extensions defined:
                if defined _EXTS (
                    rem // Loop through the extensions in the list:
                    for %%E in (%_EXTS%) do (
                        rem /* Reset flag if file with current name and iterated extension
                        rem    cannot be found; this ensures that files with all listed
                        rem    extensions do exist, otherwise no files are moved: */
                        if not exist "%%~nF%%~E" set "FLAG="
                        rem /* Reset flag if file with current name and iterated extension
                        rem    is actually a directory (though this is very unlikely): */
                        rem if exist "%%~nF%%~E\*" set "FLAG="
                        rem /* Reset flag if file with current name and iterated extension
                        rem    is already located in the target sub-directory: */
                        if exist "%%I\%%~nF%%~E" set "FLAG="
                    )
                )
                rem // Do the following steps only if the flag has not been reset:
                if defined FLAG (
                    rem // Create target sub-directory (suppress potential error message):
                    2> nul md "%%I"
                    rem // Check if there are dedicated extensions defined:
                    if defined _EXTS (
                        rem // Loop through the extensions in the list again:
                        for %%E in (%_EXTS%) do (
                            rem /* Move file with current name and iterated extension;
                            rem    nothing is overwritten due to the preceding checks: */
                            > nul move "%%~nF%%~E" "%%I\%%~nF%%~E"
                        )
                    ) else (
                        rem /* Empty list of extensions, hence just move the current file;
                        rem    if you do want to overwrite, remove the `if exist´ part: */
                        if not exist "%%I\%%F" > nul move /Y "%%F" "%%I\%%F"
                    )
                )
            )
        )
    )
    rem // Return from root directory:
    popd
)

endlocal
exit /B

The values in the Define constants here: section at the top of the script are defined to suit your sample data, but they can easily be adapted there to configure the script at one place:Define constants here:脚本顶部的部分中的值被定义为适合您的示例数据,但它们可以很容易地在那里调整以在一个地方配置脚本:

  • _ROOT : points to the directory where your input files are; _ROOT :指向输入文件所在的目录; %~dp0. points to the parent directory of the script, but you may of course specify any other absolute directory path here;指向脚本的父目录,但您当然可以在此处指定任何其他绝对目录路径;
  • _MASK : is a file pattern that matches one file per pair (only .m2v files, others are covered by _EXTS ); _MASK :是一种文件模式,每对匹配一个文件(仅.m2v文件,其他文件由_EXTS覆盖); M??? matches the four-character prefix, but you can change it to M?* , for instance, to also match prefixes like M1 or M9999 ;匹配四个字符的前缀,但您可以将其更改为M?* ,例如,也可以匹配M1M9999等前缀; if you do so, however, also edit _FILT accordingly;但是,如果您这样做,也要相应地编辑_FILT
  • _EXTS : defines a list of extensions that all must be present; _EXTS :定义所有必须存在的扩展列表; that means for a certain base file name (like M372 Houston, TX , there must exist a file per each given extension, hence M372 Houston, TX.m2v and M372 Houston, TX.mpa in our situation, otherwise these files are not going to be moved; if you do not care if such a pair is complete or not, simply state set "_EXTS=" (so clear it) and change the extension of _MASK from .m2v to .m* , so all files with an extension beginning with .m are moved;这意味着对于某个基本文件名(如M372 Houston, TX ,每个给定的扩展名都必须存在一个文件,因此在我们的情况下M372 Houston, TX.m2vM372 Houston, TX.mpa ,否则这些文件不会被移动;如果您不在乎这样的一对是否完整,只需 state set "_EXTS=" (所以清除它)并将_MASK的扩展名从.m2v更改为.m* ,所以所有文件以扩展名开头与.m一起移动;
  • _FILT : constitutes an additional filter for file names in order to exclude wrong files; _FILT :构成文件名的附加过滤器,以排除错误文件; this currently also reflects a four-character prefix, but if this is not always the case, just change M[0-9][0-9][0-9] to M[0-9]* ;这目前也反映了一个四字符前缀,但如果并非总是如此,只需将M[0-9][0-9][0-9]更改为M[0-9]* if you do not want to filter, set this to .* , so it matches everything;如果您不想过滤,请将其设置为.* ,以便匹配所有内容;
  • _SEPS : defines the character(s) to split the base file name in order to derive the respective sub-directory, so everything ending before that character and beginning after the first SPACE is the resulting sub-directory name; _SEPS :定义用于拆分基本文件名的字符以派生相应的子目录,因此在该字符之前结束并在第一个SPACE之后开始的所有内容都是生成的子目录名称; if you do not define a character here, the whole remaining base file name (so everything after the first SPACE until but not including the (last) . ) is taken;如果您未在此处定义字符,则将采用整个剩余的基本文件名(因此第一个SPACE之后的所有内容,直到但不包括 (last) . );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows批处理文件:根据输入文件(目标文件名)重命名文件(可能在多个文件夹中) - Windows batch file: rename files (possibly in multiple folders) based on input file (of target filenames) 根据文件名批量创建文件夹,并将多个相关文件移动到创建的文件夹中 - Batch Create a Folder Based on Filename, and Move Multiple Related Files to The Created Folder 批处理命令基于文件名创建文件夹并将文件/文件夹移动到创建的文件夹 - Batch command to create folder based on filename and move files/folders to created folder 批量创建基于部分文件名的文件夹并将文件移动到该文件夹​​中 - Batch create folders based on part of file name and move files into that folder 根据部分文件名创建文件夹并将文件移动到创建的文件夹中 - Create Folders based on part of file name and move files into the created folder 批处理文件以创建文件夹并根据文件名移动文件 - Batch file to make folders and move files according to filenames 使用批处理文件创建文件夹和移动文件 - Create folders and move files with batch-file 批处理文件,用于基于文件名创建文件夹并移动文件 - Batch file for creating folders based on filenames, and moving files 从Windows批处理中的多个文件夹复制文件 - Copying files from multiple folders in windows batch 创建文件并批量发送到多个文件夹? - Create file and send to multiple folders in batch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM