简体   繁体   English

根据文件名将文件移动到文件夹

[英]Move files to folders based on file name

I am new to batch files although have searched thoroughly and found topics with a similar BUT not covering what I need. 我是批处理文件的新手,尽管已进行了彻底搜索并找到了与我所需要的内容类似的主题,但是却没有涉及。

I work with lots of documents (.pdf, .doc, .xls ) saved in C:\\Tempfolder. 我处理保存在C:\\ Tempfolder中的许多文档(.pdf,.doc,.xls)。 once I am done editing I save the file name with 9 digit numbers eg( 305123123.pdf or 306123123.pdf or .doc ) 完成编辑后,我用9位数字保存文件名,例如(305123123.pdf或306123123.pdf或.doc)

I am looking to create a batch file which will automate move the files that start with 305 to C:\\Users\\Omer\\Documents\\aaCompany or if 306 to C:\\Users\\Omer\\Documents\\bbCompany 我正在寻找一个批处理文件,它将以305开头的文件自动移动到C:\\ Users \\ Omer \\ Documents \\ aaCompany,或者将306移到C:\\ Users \\ Omer \\ Documents \\ bbCompany

I can have upwards of 200 files in the folder at any one time when I decide to process. 当我决定进行处理时,我随时可以在该文件夹中存储多达200个文件。

I am also curious if the batch file can monitor C:\\Tempfolder and move the files 305 or 306 without executing it 我也很好奇批处理文件是否可以监视C:\\ Tempfolder并在不执行的情况下将文件305或306移动

Help on this is greatly appreciated. 非常感谢您对此的帮助。
I hope I have provided sufficient information to see if this is feasible. 我希望我提供了足够的信息以查看这是否可行。

You can make something like this : 你可以做这样的事情:

@Echo off &cls

::The Input Folder
set $Dossier="C:\Tempfolder"

::The Output Folders
set $Out305="C:\Users\Omer\Documents\aaCompany"
set $Out306="C:\Users\Omer\Documents\bbCompany"

::The extensions to wait
set "$Format=*.pdf,*.xls,*.doc"

setlocal enabledelayedexpansion
:Boucle
cls&echo Waiting for file ...
for /f %%a in ('dir /b/a-d %$Dossier%\%$Format% 2^>nul') do (
 set "$Fichier=%%a"
 echo Treating -^> %%a
 if "!$Fichier:~0,3!"=="305" move "%%~nxa" %$Out305%
 if "!$Fichier:~0,3!"=="306" move "%%~nxa" %$Out306%
)

::Waiting ~5 secondes
ping localhost -n 6 >nul

::Return to the loop
goto:Boucle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows批处理 - 根据文件名和扩展名将文件移动到文件夹 - Windows batch - Move files to folders based on file name & extension 批量创建基于部分文件名的文件夹并将文件移动到该文件夹​​中 - Batch create folders based on part of file name and move files into that folder 根据部分文件名创建文件夹并将文件移动到创建的文件夹中 - Create Folders based on part of file name and move files into the created folder 根据文件名将文件移动到文件夹中 - Move files into folders based on their names 在Windows中将文件移动到具有相同名称的文件夹 - Move files to folders with same name in Windows 在Windows 7中根据文件路径更改文件名和移动文件 - Change file name and move files based on file path in Windows 7 根据部分文件名批量创建文件夹并将文件移动到文件夹 - Batch create folder based on partial file name and move files to folder 使用批处理文件创建文件夹和移动文件 - Create folders and move files with batch-file 根据文件日期移动文件夹中的文件 - Move files in folders dependent on the file date Windows批处理脚本,用于根据用于巨大数据量的文件名将文件移动到其他文件夹 - Windows Batch Script for moving files to different Folders based on File Name for Huge Data Volume
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM