|
Answer» Hi, I want my batch file to find all of the *.exe files in a directory and its subdirectories. When it has done that I want it to move all of the *.exe files it finds into another directory. How can this be done?this was SOMETHING i was trying to figure out for a while, 3 seconds ago i figured it out. this is all you need.. replace %1 with original directory , and %2 with the directory your moving to.
@echo off cd\%2 move c:\%1\*.exe exit
@echo off dir /s C:\*.exe
way easierCode: [Select] @echo off for /F "delims=" %%i in ('dir /B /A-D /S *.exe') do ( echo %%i rem move %%i c:\destination ) Ok, if those replys work, then im a real noob, i tried them all but they didnt do what i wanted. I will try to explain it more fully. what i want the batch file to do is to find the *.exe files in a directory using dir /s /b C:\test\*.exe so that it will find all of the *.exe files in test and its subdirectories. then, when it has found the *.exe files in test and its subdirectories, i want it to move all of those *.exe files into a new directory. I had thought that this might work move /y /s c:\test\*.exe c:\test2\ but the move command will not accept the /s command to search subdirectories for files. is there a way that these two command can be JOINED so that the batch file will search the directory then move the files to a new, specified directory.
oh, and can the replace command use the filenames of the files it replaces, eg name1.txt is replaced with name2.txt, and name2.txt changes its name to name1.txt?
this is all for school, my computers teacher asked us how we could find out who was playing games by making a logfile (with the username,computername,time and date in it) using a batch to generate it, hidden as an *.exe and how the games could be removed without the teacher having to do anything with anybody's storage space.what is your batch file like ? and what error messages you have got? don't just say it did not work.Try looking into XCOPY
http://www.ss64.com/nt/xcopy.html
What I tried was this Code: [Select]@echo off move (dir /s /b *.exe) C:\testQuote What I tried was this Code: [Select]@echo off move (dir /s /b *.exe) C:\test you can't do that with move command check the help, type move /? on the command prompt. move only moves a directory path or file(s) (with wildcards support). the output of the "dir" command list out a list of files which the move command cannot process. you got to have a for loop to loop over these files and use the move command to move each individual files to the new location. well i realised that when it game error messages. now i am using xcopy to copy the files as sort of a physical log. then i want it to replace the *.exe files with a special one I have prepared earlier. the replace command wont let you replace specific files, not EVEN ONES with the *. So i am trying to use a for command to get the name of the executable that has been copied, rename the special .exe with that name and move the renamed special exe into the original path the name came from. Unfortunatley i dont understand the for command one bit, and need some help
|