Page 1 of 1

forach batch files in dir and run

Posted: 11 Sep 2010 03:22
by melvin
hi,

im trying to loop trought a dir with batch files and run the batch files inside.
After the batch file is run it can be deleted or moved to a other folder

the script in the batch files that i want to loop trought look like this:
"C:\Program Files\EraHW\Aries\EraHW.exe" -a "T:\Programma\edr_files\36089l.txt"

I also have another problem with moving files from one folder to antoher:

xcopy "\\Bdfs2k3\ARIES_data\Programma\edr_files" "C:\Program Files\EraHW\Aries\Progetti\Aries1" /C /R
xcopy "\\Bdfs2k3\ARIES_data\Programma\m1_files" "C:\NEXT\DataPrg" /C /R

When the file already exist it ask to overwrite by typing Y or N, so my batch file stops
I dont want it to stop, so is there any way i can kill this message by setting the overwrite value to YES or NO as default?

Melvin

Re: forach batch files in dir and run

Posted: 11 Sep 2010 04:28
by orange_batch
Something tells me your trying to do things inefficiently. :P

Follow any command in Command Prompt with /? for help and usage information.

-The /Y switch in xcopy will overwrite destination files.

-Moving and copying are different.

-To run each .bat file in a directory and then move or copy the .bat file:

Code: Select all

for %%x in ("C:\...\Target Folder\*.bat") do (
call "%%x"
move /y "%%x" "Destination Path"
---OR---
xcopy "%%x" "Destination Path" /c /r /y
)