Batch file bat文件根据文件名将文件移动到月份文件夹

Batch file bat文件根据文件名将文件移动到月份文件夹,batch-file,Batch File,我的文件夹中有文件(C:/location1)。文件如下: A-14-0005 - Title1 - 06202017.pdf B-14-1111 - Title2 - 06202017.pdf B-15-7676 - Title3 - 06202017.pdf 我需要将这些移动到另一个位置(c:/location2)。如果当前月份为1月,则创建文件夹2017(今年),然后创建子文件夹1月,如果当前月份为6月,则创建子文件夹6月。然后将3个文件移动到此文件夹中 我以前没有写过一个批处理文

我的文件夹中有文件(
C:/location1
)。文件如下:

 A-14-0005 - Title1 - 06202017.pdf
 B-14-1111 - Title2 - 06202017.pdf
 B-15-7676 - Title3 - 06202017.pdf
我需要将这些移动到另一个位置(
c:/location2
)。如果当前月份为1月,则创建文件夹
2017
(今年),然后创建子文件夹
1月
,如果当前月份为6月,则创建子文件夹
6月
。然后将3个文件移动到此文件夹中

我以前没有写过一个批处理文件,正在寻找一些关于创建一个批处理文件以开始此任务的帮助/想法。任何其他地方的链接作为我的教程开始将是伟大的以及。谢谢

@echo off
set month-num=%date:~3,2%
set year-num=%date:~6,10%
IF "%month-num:~0,1%"=="0" SET month-num=%month-num:~1%
FOR /f "tokens=%month-num%" %%a in ("January February March April May June July August September October November  December") do set mo-name=%%a

if not exist "C:\location2\%year-num%" md C:\location2\%year-num%\%mo-name%"
copy "C:\location1\A-14-0005 - Title1 - 06202017.*" "C:\location2\%year-num%\%mo-name%\" /y
copy "C:\location1\B-14-1111 - Title2 - 06202017.*" "C:\location2\%year-num%\%mo-name%\" /y
copy "C:\location1\B-15-7676 - Title3 - 06202017.*" "C:\location2\%year-num%\%mo-name%\" /y
pause
结果的样本树:

> Tree /F .
C:\LOCATION2
└───2017
    └───Jun
            B-15-7676 - Title3 - 06202017.pdf
            B-14-1111 - Title2 - 06202017.pdf
            A-14-0005 - Title1 - 06202017.pdf

为什么一月被缩短为一月,而六月被保留为六月而不是六月?它可以是一月。你有具体的问题吗?如果没有,那么让我建议你开始收集你自己的想法,并开始根据这些想法实施脚本;当你有问题的时候,回到这里。如果你希望有人为你写剧本,那你就大错特错了。请学习!那么扩展名呢?您的文件名确实缺少扩展名吗?假定文件名只是一个示例,将它们静态地放在一个批中没有多大用处。还需要移动而不是复制。文件扩展名将是.pdfWell done,Aacini<代码>;)行动,你不是亚奇尼!干得好。。。为了更清楚,我只想使用数组的完整
月份
名称。lotpings,当我尝试从我的c:\users\public位置运行此程序时,它说不支持UNC路径。我确实需要从网络共享位置运行它。如何纠正这个问题?但是
c:\users\public
是本地的,所以我假设批本身存储在共享上?如何设置Dir1/Dir2?
> Tree /F .
C:\LOCATION2
└───2017
    └───Jun
            B-15-7676 - Title3 - 06202017.pdf
            B-14-1111 - Title2 - 06202017.pdf
            A-14-0005 - Title1 - 06202017.pdf