Your code does not work, neither do my old very simple "copy moustique.exe c:\test" anymore... and i rebooted.
Wtf?
Blogs > Murlox |
Murlox
France1699 Posts
Your code does not work, neither do my old very simple "copy moustique.exe c:\test" anymore... and i rebooted. Wtf? | ||
yh8c4
108 Posts
it just takes ages to run if you have all your stuff in c:\ (since the copy only starts when dir has finally looked into every folder in C:\ for that file (no way to stop the search after the first found, afaik)). its a whole lot faster if you know that it's for example somewhere in C:\users (which is probably where your desktop folder is), so try md C:\test FOR /F %%f IN ( '"dir C:\Users\moustique.exe /s /b"' ) DO copy %%f C:\test | ||
Murlox
France1699 Posts
But even a very simple COPY command does not work anymore unless i specify the exact path, although it did work with no path at all minutes ago, so i suspect the .bat files to be somehow inneffective now? Thank you anyway, i will look why those .bat refuse to work any longer and will then try your code. Edit : I mean, even md c:\test doesn't work! | ||
yh8c4
108 Posts
| ||
Murlox
France1699 Posts
Ok, so : md C:\test FOR /F %%f IN ( '"dir C:\Users\moustique.exe /s /b"' ) DO copy %%f C:\test does create c:\test, but does not copy moustique.exe in it for me. On the other hand, md c:\test copy moustique.exe c:\test does create c:\test and copies moustique.exe in it Problem here, the .bat has to be in the same repertory as moustique.exe to work | ||
yh8c4
108 Posts
| ||
Murlox
France1699 Posts
Edit : even with md C:\test FOR /F %%f IN ( '"dir C:\Documents and Settings\Murlox\Bureau\moustique.exe /s /b"' ) DO copy %%f C:\test It still does not do the trick. Won't copy. Moreover, this is not really the direction i want to go, since what I really want is not to input any path at all, (.bat should find the file itself) | ||
yh8c4
108 Posts
| ||
Murlox
France1699 Posts
| ||
Adeny
Norway1233 Posts
| ||
Murlox
France1699 Posts
We are right on the point mate :-) I think basic dos commands can do my job, well i hope so. If i manage to get this DIR or COPY or XCOPY command to look for my file without feeding them the path of it... @yh8c4 : /b after DIR is for clarification (no summary) /s after DIR is to display files in specified directory and all subdirectories. I think this does not mean every subdirectories of the drive though, but just the subdirectories of specified directory... Which is not enough in my case ;7 May be DIR is not the proper command? dir \ moustique.exe /s finds it ! | ||
yh8c4
108 Posts
md C:\test FOR /F "delims=" %%f IN ( '"\moustique.exe /b /s"' ) DO copy "%%f" C:\test faster version with a small hint to your desktop... md C:\test FOR /F "delims=" %%f IN ( '"C:\"Documents and Settings"\moustique.exe /b /s"' ) DO copy "%%f" C:\test better copy-paste, this has some more "s... | ||
Murlox
France1699 Posts
Neither your versions work... | ||
yh8c4
108 Posts
On July 18 2009 08:46 Murlox wrote: Hei da, We are right on the point mate :-) I think basic dos commands can do my job, well i hope so. If i manage to get this DIR or COPY or XCOPY command to look for my file without feeding them the path of it... @yh8c4 : As I understand it, /b after DIR is for clarification (no summary) /s after DIR is to display files in specified directory and all subdirectories. I think this does not mean every subdirectories of the drive though, but just the subdirectories of specified directory... Which is not enough in my case ;7 May be DIR is not the proper command? /b outputs the complete path to the file + filename and no this date, size etc crap, we just need the path + name to feed it to the copy command /s if the specified directory is \ then /s means checking each and every directory on that drive the dir command isnt optimal for your problem (since you probably want the search to end once the file has been located), but there's nothing which gets the job done (that is providing the source paramter for the copy command) | ||
Murlox
France1699 Posts
Because DIR \ moustique.exe /s finds the file ; how can use this result as a source for COPY ? | ||
yh8c4
108 Posts
![]() On July 18 2009 09:06 Murlox wrote: Btw, how do you use the result provided by the DIR command with the COPY command ? Because DIR \ moustique.exe /s finds the file ; how can use this result as a source for COPY ? thats what the FOR loop does the stuff in the parantheses after IN is a set of dir results. you basically say: let %%f be a member of this set, then for each member in that set do copy %%f c:\test. you know what i mean? for each item in the IN ( ... ) set copy is called once, and %%f gets substituted with that item. | ||
Murlox
France1699 Posts
And FOR loops this whole system. Am i getting it right? | ||
Murlox
France1699 Posts
Thank you very much for you help yh8c4, was a pleasure ![]() | ||
yh8c4
108 Posts
![]() i put some files in c:\tmp\x (printed with /b /s) then i print out the content of x.bat (with the type command) then i run x.bat, and you can see that copy is run 4 times, because the call for dir *.txt /b /s yielded 4 results, which are the contents inside the IN ( ). each time copy is run, it is run with a different source parameter, because each time the %%f gets substituted with a different item from the IN ( ) set. i'm 100% sure, that md C:\test FOR /F "delims=" %%f IN ( '"\moustique.exe /b /s"' ) DO copy "%%f" C:\test works, just run it and make a screenshot ![]() | ||
yh8c4
108 Posts
md C:\test FOR /F "delims=" %%f IN ( '"dir \moustique.exe /b /s"' ) DO copy "%%f" C:\test | ||
| ||
![]() StarCraft 2 StarCraft: Brood War Dota 2 Counter-Strike Super Smash Bros Heroes of the Storm Other Games summit1g16759 tarik_tv11473 Grubby6205 Day[9].tv1179 Beastyqt577 shahzam544 C9.Mang0230 PiGStarcraft118 Maynarde86 Trikslyr59 Organizations Other Games StarCraft 2 StarCraft: Brood War |
Rex Madness
MaxPax vs Ryung
ByuN vs Rogue
BSL
Replay Cast
WardiTV Spring Champion…
herO vs SKillous
Classic vs Bunny
Korean StarCraft League
SOOP
Classic vs Rogue
CranKy Ducklings
WardiTV Spring Champion…
Cure vs TriGGeR
MaxPax vs Dark
Replay Cast
Afreeca Starleague
Rain vs Action
Bisu vs Queen
[ Show More ] Wardi Open
Afreeca Starleague
Snow vs Rush
hero vs Mini
Online Event
The PondCast
WardiTV Spring Champion…
Rogue vs Zoun
Clem vs ShoWTimE
Tenacious Turtle Tussle
|
|