|
Answer» Hi,
I have a very simple BATCH file script to copy files in the current folder to another folder, but it also copies the actual .bat file. How can I EXCLUDE the .bat file from also being copied?
here is what I have so far:
copy /-Y *.xml F:\\Test Exit
I tried this:
except *.bat copy /-Y *.xml F:\\Test Exit
with and without brackets but it does not work.
Any help WOULD be appreciated. Jaime
The simple way is to have the batch file itself in another directory. Let's say your stuff in in D:STUFF and the bat file name MYBAT.BAT is in D:\BAT then go into D:STUFF directory and give the command d:\bat\mybat Which will only operate on files in the current directory and sub directories.
Sounds LIKE a good workaround, but I would like for it to send files from the current dir. rather than pull files from the current dir.
The target folder is a watched folder where all files in it are pulled into a translations program and automatically added to a TRANSLATION workflow project. So I do want to avoid adding any files to the watched folder that do not belong there.
Jaime If you use the copy command with the *.xml filemask then only files with extension .xml will be copied, and files with the extension .bat (or any other extension except .xml) will be ignored. Check your code.
Yes, sorry, I meant to write *.* so as to copy all files in the directory.
Thanks, Jaime You can use a FOR loop and DIR to list the files to copy and skip the batch file's own name (which is %0) (that is a ZERO)
Code: [Select]echo off for /f "delims=" %%A in ('dir /b /a-d') do if not "%%A"=="%0" copy /-Y "%%A" F:\\Test
|