在文件夹中自动把文件 [英] Put files automatically in folders

查看:136
本文介绍了在文件夹中自动把文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有成千上万的JPG文件命名为这样的aaa0001.jpg,aaa0002.jpg,aaa0003.jpg,
bbb0001.jpg,bbb0002.jpg,bbb0003.jpg,ccc0001.jpg,ccc0002.jpg,ccc0003.jpg等一文件夹中。

I have thousands of JPGs named like this "aaa0001.jpg, aaa0002.jpg, aaa0003.jpg, bbb0001.jpg, bbb0002.jpg, bbb0003.jpg, ccc0001.jpg, ccc0002.jpg, ccc0003.jpg etc." in one folder.

我创建的文件夹26这样的AAA,BBB,CCC,DDD等。

I have created 26 folders like this aaa, bbb, ccc, ddd etc.

是否有可能创建一个脚本,并将所有图像的相应文件夹?

Is it possible to create a script that sets all the images in the appropriate folder?

结果aaa0001.jpg,aaa0002.jpg,aaa0003.jpg到文件夹AAA,
bbb0001.jpg,bbb0002.jpg,bbb0003.jpg到文件夹BBB等。

Result "aaa0001.jpg, aaa0002.jpg, aaa0003.jpg" into folder "aaa", "bbb0001.jpg, bbb0002.jpg, bbb0003.jpg" into folder "bbb" etc.

感谢您!

我的系统是windows XP SP3教授...

My system is windows XP prof SP3...

推荐答案

这会是这样在Windows / DOS批处理文件。

It would go like this in a Windows/dos batch file.

语句%FP:0,3〜%确定哪些文件名的一部分被用作文件夹名。 0,3手段:从第一个字符,并在接下来的3个字符。
所以一个名为 aaa001-01.jpg 会给出一个文件夹 AAA 。结果
有一个名为文件 abc001_03.jpg 进入文件夹 001 更改语句<$​​ C $ C>%FP :〜3.3%

The statement %fp:~0,3% determines which part of the filename is used as a foldername. 0,3 means: from the first character and the next 3 chars. so a file named aaa001-01.jpg will give a folder of aaa.
To have files named abc001_03.jpg go into folder 001 you change the statement to %fp:~3,3%

for %%a in (*.jpg) do call :copyfile %%a
goto :eof

:copyfile
set fp=%1
set folder=%fp:~0,3%

rem remove echo on the next line...
echo copy "%1" "%folder%"
rem or for moving:   move /Y "%1" "%folder%"

goto :eof

这篇关于在文件夹中自动把文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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