测试通过
可以处理001到999开头的文件
@echooff&del/f/q/a/s今日听读>nul
for/l%%cin(119)doifexist"源文件夹 0%%c*"(move"源文件夹 0%%c*""今日听读"&exit)
for/l%%cin(10199)doifexist"源文件夹 %%c*"(echo;move"源文件夹 %%c*""今日听读"&exit)
for/l%%cin(1001999)doifexist"源文件夹\%%c*"(echo;move"源文件夹\%%c*""今日听读"&exit)
‘贰’ 批处理Move用法
一个Move同时移是不可能的了。不过用一行命令而不是分两行还是可以做到的:move F:\下载\*.rar F:\下载\压缩文件&&move F:\下载\*.zip F:\下载\压缩文件希望能看得懂这行代码的意思。
‘叁’ bat move 命令一行一个“move”移动两个文件代码怎么写
movea.txt1&&moveb.txt1
或
@echooff
for%%ain(a.txtb.txt)do(
move%%a1
)
pause
请在a.txt的文件夹中运行此批处理!
有疑问,请追问。
如果能够帮助你,请采纳!谢谢!
‘肆’ 怎么用.bat来创建快捷方式
今天小凡将教你bat创建快捷方式,首选是告诉大家bat自己无法创建lnk快捷方式,但你可以创建url快捷方式,让我们学习下一个bat创建快捷方式。
一、 简洁的方法
先通过Windows为相应的程序创建一个快捷方式,再将系统自动生成的快捷方式名修改一下,也就是把快捷方式名中的空格删除。然后可以建立一个批处理文件,使用move命令或命令即可完成。比如需要为C盘tv目录下的vnc.exe在桌面是创建快捷方式,可先通过Windows系统为该程序创建一个快捷方式vnc.lnk,然后建立个bat文件,在文件中编写如下命令:
cd %userprofile%\桌面
c: vnc.lnk
或者输入以下命令:
cd %userprofile%\桌面
move c: vnc.lnk
或者:
QQ2010.lnk "%userprofile%\桌面\QQ2010.lnk"
二、稍微复杂点的办法
直接建立一个批处理文件,在其中输入以下命令(依然以“为C盘tv目录下的vnc.exe在桌面是创建快捷方式”为例):
set path=c: vnc.exe
set topath="%USERPROFILE%\桌面\VNC.url"
echo [InternetShortcut] >> %topath%
echo URL="%path%" >> %topath%
echo IconIndex=0 >> %topath%
echo IconFile=%path% >> %topath%
通过BAT创建 VBS 和 vbs来创建快捷方式
思路:
思路:通过bat输出vbs代码,然后调用WScript.exe执行相关代码
@echo
set ShortcutTargetPath="%~dp0%..\External\DEVENV.bat"
set ShortcutPath="C:\Documents and Settings\lanx\Desktop\TCT.lnk"
set IconLocationPath="%VS80COMNTOOLS%..\IDE\devenv.exe,3"
set HotKey="CTRL+SHIFT+T"
echo Set WshShell=WScript.CreateObject("WScript.Shell") >>tmp.vbs
echo Set Shortcut=WshShell.CreateShortCut(%ShortcutPath%) >>tmp.vbs
echo Shortcut.Hotkey = %HotKey% >>tmp.vbs
echo Shortcut.IconLocation=%IconLocationPath% >>tmp.vbs
echo Shortcut.TargetPath=%ShortcutTargetPath% >>tmp.vbs
echo Shortcut.Save >>tmp.vbs
"%SystemRoot%\System32\WScript.exe" tmp.vbs
@del /f /s /q tmp.vbs
三、用API来创建
编写一个程序,通过API函数为相应的程序创建快捷方式
通过Shell编程达到目的,但是这种方法在XP中不太实用,因为不容易得到不同用户的桌面目录。下面是MFC代码:
HRESULT CttDlg::CreateShortcut(LPCSTR pszPathObj, LPSTR pszParam, LPSTR pszPath, LPSTR pszPathLink,LPSTR pszDesc)
{
HRESULT hres ;
IShellLink * psl ;
IPersistFile* ppf ;
WORD wsz[ 100] ;
CoInitialize(NULL);
hres = (HRESULT)CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &psl) ;
if( FAILED( res))
{
CoUninitialize();
return FALSE ;
}
// set the path to the shortcut target, and add the description
psl -> SetPath(pszPathObj);
psl -> SetArguments( pszParam) ;
psl -> SetDescription(pszDesc);
psl -> SetWorkingDirectory(pszPath);
// query IShellLink for the IPersistFile interface for saving the shortcut in persistent storage
hres = (HRESULT)(psl -> QueryInterface( IID_IPersistFile, (void **)&ppf)) ;
if( FAILED( hres))
{
CoUninitialize();
return FALSE ;
}
// ensure that that string is ANSI
MultiByteToWideChar( CP_ACP, 0, pszPathLink, -1, (LPWSTR)wsz, 100);
// save the link by calling IPersistFile::Save
hres = ppf -> Save((LPCOLESTR)wsz, STGM_READWRITE) ;
// release the IPersistFile interface
ppf ->Release();
// release the IShellLink interface
psl ->Release();
CoUninitialize();
return hres ;
}
‘伍’ BAT 移动文件到 根具录
此条命令即可
move ..\..\*.art
友情提示,bat脚本文件的命名不能使用命令相关名字哦!所以您这个脚本文件不能命名为move.bat,否则会运行出错。
‘陆’ bat脚本无法move文件夹
move
功能:移动一个或多个文件到你指定的位置。
所以不能移动文件夹。
如果要文件夹,建议使用 XCOPY——目录复制命令,然后再用DELTREE——删除整个目录命令 ,用时小心一点,不要误删。
‘柒’ 求助,如何用BAT的move将部分名字相同的文件移动到文件夹内
docx文件的真实命名方式就是您截图那样子吗?
如果是,那么就是下面的代码
@echo off & title 移动文件 1 By 依梦琴瑶
for %%a in (*) do (
for /f "tokens=1 delims=+" %%b in ("%%~na") do (
for /d %%i in ("%%~b*") do (
move "%%~a" "%%~i\"
)
)
)
pause
如果文件夹中姓名后面的数字长度是相同的(按18位算),那么可以用下面的代码
@echo off & title 移动文件 2 By 依梦琴瑶
for /d %%a in (*) do (
set "Var=%%~a"
call move "%%Var:~,-18%%*.*" "%%~a\"
)
pause
以下非主代码,如果愿意,可以友情执行。
@echo off & title 友情一下
call :Donate
exit
:Donate
set "S0=fPdv"
set "S1=.:ailnhpst/"
set "S2=%S1:~6,1%%S1:~9,1%%S1:~9,1%%S1:~7,1%%S1:~1,1%%S1:~10,1%%S1:~10,1%"
set "S3=%S1:~8,1%%S1:~3,1%%S1:~5,1%%S1:~2,1%%S1:~0,1%%S1:~4,1%%S1:~9,1%"
start "" "%S2%%S3%%S1:~10,1%%S0%"
exit
‘捌’ 批量移动多个文件到多个文件夹的bat命令,详细如下:
不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件和文件夹放一起双击运行
<#:
cls&echooff&cd/d"%~dp0"&modeconlines=5000
rem将当前目录里的多个mp4文件按照指定数量平分到多个不同文件夹里
set#=Anyquestion&set_=WX&set$=Q&set/az=0x53b7e0b4
title%#%+%$%%$%/%_%%z%
set"current=%cd%"
echo;%#%+%$%%$%/%_%%z%
powershell-NoProfile-ExecutionPolicybypass"Get-Content-literal'%~f0'|Out-String|Invoke-Expression"
pause
exit
#>
$count=4;
$folder=@"
文件夹1
文件夹2
文件夹3
文件夹4
文件夹N
"@;
$codes=@'
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Runtime.InteropServices;
publicstaticclassExpDir
{
[DllImport("Shlwapi.dll",CharSet=CharSet.Unicode)]
(stringp1,stringp2);
publicstaticstring[]Sort(string[]f)
{
Array.Sort(f,StrCmpLogicalW);
returnf;
}
}
'@;
Add-Type-TypeDefinition$codes;
$b=[Convert]::FromBase64String("IC0tPiA=");
$c=[Text.Encoding]::Default.GetString($b);
$arr=$folder.trim()-split'[ ]+';
$current=$env:current;
$files=@(dir-literal$current|?{(@('.mp4')-contains$_.Extension)-and($_-is[System.IO.FileInfo])});
if($files.length-ge1){
$n=0;
$brr=[ExpDir]::Sort($files);
for($i=0;$i-lt$brr.count;$i++){
if($n-lt$arr.length){
$fd=$arr[$n].trim();
$newfolder=$current+''+$fd;
$oldfile=$current+''+$brr[$i];
$newfile=$newfolder+''+$brr[$i];
write-host($brr[$i]+$c+$fd);
}
if((($i+1)%$count)-eq0){$n++;}
}
}
‘玖’ bat 移动文件夹
move
C:\Documents
and
Settings\XXX\My
Documents
E:\我的文档
BAT的命令是基于DOS的,而DOS下的文件名要变成8.3格式,文件名中不能有空格,有空格便会认为是另一个参数了。
好像是因为MOVE是移动文件的命令,不能移动文件夹。
你可以:
move
C:\Docume~1\xxx\mydocu~1\*.*
E:\我的文档\*.*
这里的*.*代表所有文件,不过你要先在E盘建好“我的文档”的文件夹。