Solved Moving files based on a filename

October 9, 2012 at 02:00:04
Specs: Windows Vista
Hi, looking for some help with writing a BAT file.

Moving files based on filename

1. Directory contains multiple CSV’s \Test\
2. Move files based on filename to specific sub folder:

If file like error*.csv move to \Test\Errors
If file like success*.csv move to \Test\Success
Else ignore

Any pointers?


See More: Moving files based on a filename

Report •


#1
October 9, 2012 at 02:27:29
✔ Best Answer
not tested

:: ===== script starts here ===============
::
:: GT4.bat 2012-10-09 16:23:22.73
@echo off > newfile & setLocal enableDELAYedeXpansioN

pushd \test

for /f "tokens=* delims= " %%a in ('dir/b error*.csv') do (
echo move %%a error
)
for /f "tokens=* delims= " %%i in ('dir/b success*.csv') do (
echo move %%i success
)
::====== script ends here =================


====================================
Life is too important to be taken seriously.

M2


Report •

#2
October 10, 2012 at 22:57:00
Perfect! Worked a treat.

Report •

Related Solutions


Ask Question