|
|
|
Batch File: Automating repetitive..
|
Original Message
|
Name: malbymalby
Date: August 5, 2008 at 01:03:24 Pacific
Subject: Batch File: Automating repetitive..OS: dosCPU/Ram: 1gModel/Manufacturer: amd |
Comment: I am currently using the following batch file to copy all word files on my hard drive to a specific folder: md "c:\" 2>nul for /f "delims=" %%a in ( 'dir "c:\hello\*.doc" /b /s /a-d' ) do copy "%%a" "c:\newfolder" /-y I have deliberately enabled prompting as I want to ensure that no files are overwritten. I have a lot of these files and have to do this regularly so sitting typing “n enter” each time I am prompted is not in any way desirable!!! Does anyone know how this could be written into the above batch file to automate the input of “n” then “enter”?
Report Offensive Message For Removal
|
|
Response Number 3
|
Name: Mechanix2Go
Date: August 5, 2008 at 05:43:08 Pacific
|
Reply: (edit)I'm not booted in DOS but I think this will do it. It'll preview what's to be done. Once you're satisfied, remove the ECHO from the FOR line. ::==================== @echo off
set src=c:\files set dest=d:\bakup cd %src% for %%a in (*.txt) do echo if not exist %dest%\%%a copy %%a %dest%\ ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: malbymalby
Date: August 5, 2008 at 08:02:11 Pacific
|
Reply: (edit)Thanks for that, it does seem to work to a degree however I am somewhat new to batch files as I have only recently discovered their usefulness, it is also a long time since I used dos….. I have modified the file as follows: set src=c:\hello set dest=c:\newfolder cd %src% for %%a in (*.doc) do echo if not exist %dest%\%%a copy %%a %dest%\ how do I modify this to ensure that all documents in the sub directories in the src c:\hello are also copied?
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Valerie (by Garibaldi)
Date: August 5, 2008 at 14:59:53 Pacific
|
Reply: (edit)You could set your copycmd env variable to /-y and in your original script you could try ) do echo n | copy "%%a" "c:\newfolder"
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: itguru
Date: August 6, 2008 at 22:37:12 Pacific
|
Reply: (edit)"Thanks for that, it does seem to work to a degree however I am somewhat new to batch files as I have only recently discovered their usefulness, it is also a long time since I used dos….." Actually in XP you are not using MS-DOS but NT COMMAND PROMPT (CMD.EXE)
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: Valerie (by Garibaldi)
Date: August 7, 2008 at 15:12:57 Pacific
|
Reply: (edit)"that works like a dream!!!! thanks Garibaldi, simple yet effective!!!" Thanks for coming back with that MalbyMalby. Once you're confident with your script you could add > NUL to the DO line in order not to output all the Copy queries to the screen or you could add >> path\filename to output the queries to a file in order to view them later. Good luck. Valerie.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|