moving files to folder containing substring

April 1, 2010 at 02:16:57
Specs: Windows XP
Im new to this and have been trying to make a batch file to move files on a certain folder to another folder if it contains "mapping" infront of the filename.

Here is the code i have tried but failed to accomplish the task .Any help is appreciated.

@echo off

pushd C:\Documents and Settings\User\Desktop\

for %%a in (*.csv) do (
set filename=%%~na
set filecontain=!filename:~0,7!
if !filecontain! == "mapping" move %%a "C:\Documents and Settings\User\Desktop\Storage"




See More: moving files to folder containing substring

Report •

April 1, 2010 at 05:47:45
I think all you need to do is just one correction. Change:

if !filecontain! == "mapping"


if "!filecontain!" == "mapping"

Report •

April 1, 2010 at 07:29:08
You don't need to use PUSHD and POPD when only using the MOVE command ... I guess there are other command in that batchfile as well, but if not, you can remove some commands. If you really want to navigate, use CD

Report •

Related Solutions

Ask Question