forach batch files in dir and run

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
melvin
Posts: 1
Joined: 11 Sep 2010 03:13

forach batch files in dir and run

#1 Post by melvin » 11 Sep 2010 03:22

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

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: forach batch files in dir and run

#2 Post by orange_batch » 11 Sep 2010 04:28

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
)

Post Reply