问题描述
我在目录中拥有此内容
[FOLDERS]
Atomic
Animal
Cat
flash
Zoe
[FILES]
text.txt
audio.rar
我想在这样的目录目录结构内对移动文件夹进行重新排序(大小写不敏感).我只想移动文件夹而不移动文件
I want to reorder moving folders inside an alfabetic directory structure like this (case is irrilevant). I want move only folders no files
A [Atomic, Animal]
C [cat]
f [flash]
Z [zoe]
file1.rar
file2.txt
其中A,C,f,Z是父文件夹.括号中的文件夹是MOVED文件夹,而不是CONSOLIDATED文件夹!
我可以使用哪个 .bat 命令?
where A,C,f,Z are parent folders. Folders in bracket are MOVED folders not CONSOLIDATED folders!
Which .bat command can I use?
对于所有以 A 字母开头的文件夹,我想在一个名为 A 的唯一文件夹中移动.对于以 F 字母开头的文件夹,我想将它们移动到一个名为 F 的文件夹中.
移动不是替换或合并,因为我假设所有以相同字母开头的文件夹都具有不同的名称,我只想按首个文件夹字母对其进行排序.
我不想按字母合并唯一文件夹中的文件夹,而只能按首个文件夹字母 移动 来合并唯一文件夹.
I want move inside a unique folder called A for all folders that starts with A letter. For folders that starts with F letter I want move them in a single folder called F
Moving is not replacing or merging because I assume that all folders that starts with same letter have different names, I want simply order them by first folder letters.
I don't want consolidate folders in unique folders by letter but only moving in unique folder by first folder letter.
推荐答案
@echo off
setlocal enabledelayedexpansion
rem md atomic animal cat flash zoe alfa american banda barca beta brasil cane alfa\subdir
tree
for /d %%i in (*) do (
set first=%%i
set first=!first:~0,1!
md !first! 2>nul
if not "!first!" == "%%i" move "%%i" "!first!\%%i"
)
tree
对于当前文件夹中的每个目录,请执行以下操作:
-获取第一个字母
-创建一个字母文件夹
-如果该文件夹不是一个字母文件夹,请移动它.
for every directory in the current folder do:
- get the first letter
- create the one letter folder
- if the folder isn't a one letter folder, move it.
使用tree
显示结果
这篇关于批处理命令可在目录目录结构中移动许多文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!