Solved Moving files based on content

October 9, 2012 at 02:10:03
Specs: Windows Vista
And one more.

Moving files based on content

1. Directory contains multiple error*.csv files
2. Move files as follows:

If Line 1 and column 2 = TX_DATE then move file to \Test\Errors\Cases
Else move file to \Test\Errors\CaseErrors

needs to be in BAT file, run at command.exe not cmd.exe

Appreciate any help!



See More: Moving files based on content

Report •

October 9, 2012 at 02:30:55
I dunno Vista but I never heard of command.exe

Life is too important to be taken seriously.


Report •

October 9, 2012 at 05:48:12
Maybe he means That still leaves the question unanswered of why a Vista user would want to use the old DOS emulation environment, but one thing at a time.

How To Ask Questions The Smart Way

Report •

October 9, 2012 at 18:29:58
✔ Best Answer
here's a trial-balloon, ready to be shot down in flaming tatters with massive loss of life and extensive property damage as well:
::===== begin script
@echo off & setlocal
set f=\test\errors
for %%a in (*.csv) do (
echo file: %%a
set /p z=<%%a
call :two
goto :eof

echo Line one content: %z%
for /f "tokens=2 delims=," %%b in ("%z%") do (
if /i "%%b" equ "TX_DATE" (echo move %%a %f%\Cases) else (echo move %%a %f%\CaseErrors)
:: end

disclaimer no. 1: if there are any commas in the first item ("column"), this will fail.
disclaimer no. 2: this one is test-only (shoots blanks). remove 'echo' for live ammo.
disclaimer no. 3: this does not take into account the bizarre "command.exe" requirement that no-one has yet figured out.

Report •

Related Solutions

October 10, 2012 at 22:59:57
Yes, I am a Vista user, but the script was to run on a Win XP machine.


Machine is locked down to running the 'Command Prompt', RUN - Command, and cannot use cmd.exe. But appears OK when run it BAT file.

This script also worked very well!

Thanks nbrane.

Report •

Ask Question