Board logo

标题: [文件操作] 批处理如何批量将文件名中具有相同前缀字符串的文件移动到以该字符串命名的文件夹里 [打印本页]

作者: a574045075    时间: 2015-11-8 12:42     标题: 批处理如何批量将文件名中具有相同前缀字符串的文件移动到以该字符串命名的文件夹里

本帖最后由 pcl_test 于 2016-7-7 20:01 编辑

例如
MM\Sound\WaveArchives\WARC_2_0.wav移动到MM\Sound\WaveArchives\WARC_2\
MM\Sound\WaveArchives\WARC_2_1.wav移动到MM\Sound\WaveArchives\WARC_2\
MM\Sound\WaveArchives\WARC_2_2.wav移动到MM\Sound\WaveArchives\WARC_2\

MM\Sound\WaveArchives\WARC_3_0.wav移动到MM\Sound\WaveArchives\WARC_3\
MM\Sound\WaveArchives\WARC_3_1.wav移动到MM\Sound\WaveArchives\WARC_3\
MM\Sound\WaveArchives\WARC_3_2.wav移动到MM\Sound\WaveArchives\WARC_3\

MM\Sound\WaveArchives\WARC_BGM_ALL_0.wav移动到MM\Sound\WaveArchives\WARC_BGM_ALL\
MM\Sound\WaveArchives\WARC_BGM_ALL_1.wav移动到MM\Sound\WaveArchives\WARC_BGM_ALL\
MM\Sound\WaveArchives\WARC_BGM_ALL_2.wav移动到MM\Sound\WaveArchives\WARC_BGM_ALL\

MM\Sound\WaveArchives\WARC_SE_0.wav移动到MM\Sound\WaveArchives\WARC_SE
MM\Sound\WaveArchives\WARC_SE_1.wav移动到MM\Sound\WaveArchives\WARC_SE
MM\Sound\WaveArchives\WARC_SE_2.wav移动到MM\Sound\WaveArchives\WARC_SE
作者: 707093864    时间: 2015-11-8 14:53

用move。。。。。。。
作者: a574045075    时间: 2015-11-8 14:57

回复 2# 707093864
能不能帮帮忙弄个批量BAT啊?
作者: a574045075    时间: 2015-11-8 16:03

本帖最后由 pcl_test 于 2016-7-7 20:02 编辑

如何把TXT移动到与TXT文件名相同的文件夹
例如:
BANK_DENSETU.TXT移动到Sound\Banks\BANK_DENSETU
BANK_ENVIROMENT.TXT移动到Sound\Banks\BANK_ENVIROMENT
BANK_FOLK.TXT移动到Sound\Banks\BANK_FOLK
BANK_FUKUROU.TXT移动到Sound\Banks\BANK_FUKUROU
BANK_ITEM.TXT移动到Sound\Banks\BANK_ITEM
作者: 707093864    时间: 2015-11-8 16:17

没看懂你的意思
作者: DAIC    时间: 2015-11-8 16:54

  1. @echo off
  2. for %%i in (*.txt) do (
  3.     move /y "%%i" "Sound\Banks\%%~ni"
  4. )
复制代码

作者: DAIC    时间: 2015-11-8 17:00

test.bat 放在B文件夹下面
  1. @echo off
  2. for /f "delims=" %%i in ('dir /b /s *.txt') do (
  3.     move /y "%%i" "..\C\"
  4. )
复制代码

作者: 依山居    时间: 2015-11-8 17:07

楼主好可怜。
作者: a574045075    时间: 2015-11-8 17:53

本帖最后由 pcl_test 于 2016-7-7 20:02 编辑

怎么移动这些WAV文件到相对应的文件夹?
看一楼!!!
作者: /zhqsystem/zhq    时间: 2015-11-9 00:19

本帖最后由 /zhqsystem/zhq 于 2015-11-9 03:55 编辑

回复 9# a574045075
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /f "delims=" %%i in ('dir/a-d/s/b/l/on "%~dp0\MM\Sound\WaveArchives\*.wav"') do (
  4. set "name_dpnxi=%%i"&set "name_nxi=%%~nxi"
  5. set "name_nxi=!name_nxi:_=\!"
  6. for /f "delims=" %%j in ("!name_nxi!") do (
  7.   set name_dpnxi=!name_dpnxi:_%%~nxj=!
  8.   echo "%%i" "!name_dpnxi!\%%~nxj"
  9. )
  10. )
  11. pause
复制代码

作者: a574045075    时间: 2015-11-9 06:54

本帖最后由 a574045075 于 2015-11-9 08:08 编辑

回复 10# /zhqsystem/zhq
这个不行 文件还是在原来的位置?

"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2_0.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2\0.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2_1.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2\1.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2_2.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_2\2.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3_0.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3\0.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3_1.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3\1.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3_2.wav
" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_3\2.w
av"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_bgm_all
_0.wav" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc
_bgm_all\0.wav"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_bgm_all
_1.wav" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc
_bgm_all\1.wav"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_bgm_all
_2.wav" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc
_bgm_all\2.wav"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se_0.wa
v" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se\0
.wav"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se_1.wa
v" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se\1
.wav"
"c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se_2.wa
v" "c:\documents and settings\administrator\桌面\mm\sound\wavearchives\warc_se\2
.wav"
请按任意键继续. . .
作者: 依山居    时间: 2015-11-9 09:06

哈哈,简直蠢。
作者: a574045075    时间: 2015-11-9 09:07

本帖最后由 a574045075 于 2015-11-9 09:09 编辑

回复 12# 依山居
不好意思 我对批处理一点不懂 又没时间学习!
作者: /zhqsystem/zhq    时间: 2015-11-9 17:11

回复 11# a574045075
写的太完整就会使人懒惰,如果是伸手党我认可不发这个帖子,只把主要代码发出来其实是最好的,希望楼主不要做伸手党回显值等于实际运行值简单替换都不会的话直接回我删了此帖,免得浪费空间
作者: 依山居    时间: 2015-11-15 18:33

回复 13# a574045075


    有时间问没时间学?
作者: wdh123    时间: 2016-8-6 10:25

回复 10# /zhqsystem/zhq


    稍微修改一下,可以用在别的地方.谢谢!




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2