2015-04-04 114 views
-3

您好,我需要一个脚本来创建文件夹到一组图像,并使用映像名称重命名这些文件夹,例如批处理或PowerShell。 我不是一个程序员,不讲英语遗憾用于创建文件夹的脚本

Directory root: 
     AA_1.jpg 
     AA_2.jpg 
     AA_3.jpg 
     BB_0.jpg 
     BB_1.jpg 
     BB_2.jpg 

Directory root: 
      subdirectoryAA 
       AA_1.jpg 
       AA_2.jpg 
       AA_3.jpg 
      subdirectoryBB 
       BB_0.jpg 
       BB_1.jpg 
       BB_2.jpg 
+1

那么也许你应该考虑成为一名程序员。编写一个你描述的脚本通常是程序员将要学习的第一件事情。 – Touffy 2015-04-04 15:54:42

+0

我是设计师只是想自动化这个过程 – 2015-04-04 16:06:49

+2

我们不是一个脚本写作服务,而是一个帮助程序员和编程爱好者的社区 – Matt 2015-04-04 16:30:36

回答

1

的一个起点:下面的代码复制,粘贴到记事本,改线,其中pushd发生,保存为anyname.bat(参见输出示例中的29448342.bat

@ECHO OFF >NUL 
SETLOCAL enableextensions disabledelayedexpansion 

     rem Change the current directory to "Directory root" 
    pushd "D:\test\29448342" 
     rem main loop 
    for %%G in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
      rem make destination directory 
     md %%G%%G 2>NUL 
      rem move files of a given pattern to destination directory 
     if exist "%%G%%G*.jpg" move "%%G%%G*.jpg" "%%G%%G\" 
    ) 
     rem Change the current directory back (cf. previous pushd) 
    popd 

ENDLOCAL 
goto :eof 

输出

d:\bat>dir /B /S D:\test\29448342\*.jpg 
D:\test\29448342\AA_1.jpg 
D:\test\29448342\AA_long name 2.jpg 
D:\test\29448342\FF_1.jpg 
D:\test\29448342\FF_long name 2.jpg 
D:\test\29448342\GG_1.jpg 
D:\test\29448342\GG_long name 2.jpg 

d:\bat>D:\bat\StackOverflow\29448342.bat 
D:\test\29448342\AA_1.jpg 
D:\test\29448342\AA_long name 2.jpg 
     2 file(s) moved. 
D:\test\29448342\FF_1.jpg 
D:\test\29448342\FF_long name 2.jpg 
     2 file(s) moved. 
D:\test\29448342\GG_1.jpg 
D:\test\29448342\GG_long name 2.jpg 
     2 file(s) moved. 

d:\bat>dir /B /S D:\test\29448342\*.jpg 
D:\test\29448342\AA\AA_1.jpg 
D:\test\29448342\AA\AA_long name 2.jpg 
D:\test\29448342\FF\FF_1.jpg 
D:\test\29448342\FF\FF_long name 2.jpg 
D:\test\29448342\GG\GG_1.jpg 
D:\test\29448342\GG\GG_long name 2.jpg 

d:\bat> 

资源(必读):

+0

谢谢,脚本工作完美 – 2015-04-05 01:48:24

+0

非常好的你帮助他。 – FoxDeploy 2015-04-05 15:19:20

相关问题