<r>Hello guys, I'm new overhere so I got problem that I got about 1300 folder where I need to copy some licence file so I need some batch or something like that solution how to do that.<br/>
For example I got file in C:/licence.bin that i need to copy in<br/>
<br/>
C:/SomeFolder/<br/>
- Users<br/>
------ Joe<br/>
------------ Joe1<br/>
------------ Joe2<br/>
------------ Joe3<br/>
------ Kevin<br/>
------------ Kevin's_Son<br/>
------ MadMax<br/>
<br/>
and I want that licence.bin into last empty sub-folder of Users, like joe 1,2,3, Kevin's Son and MadMax <E>:)</E> Can someone give me some idea or solution?</r>
Copy one file to seperate folder
Moderator: DosItHelp
Re: Copy one file to seperate folder
Please note that windows uses \ in paths, not /
Also, you should learn to use the markup language supported by this site - html does not work. The buttons at the top of the post editor work well, and are pretty self-evident.
The following one liner should do the trick from the command line
If you want the command in a batch script, then you must double the percents
The above assumes that by "empty sub-folder" you mean a folder that does not contain any other folders, but may have files.
If you truly mean empty, (no files or folders), then remove the /ad option from the dir command
Dave Benham
Also, you should learn to use the markup language supported by this site - html does not work. The buttons at the top of the post editor work well, and are pretty self-evident.
The following one liner should do the trick from the command line
Code: Select all
for /r "c:\SomeFolder\Users" /d %F in (*) do @dir /b /ad "%F" | findstr "^" >nul || copy "c:\licence.bin" "%F" >nul
Code: Select all
@echo off
for /r "c:\SomeFolder\Users" /d %%F in (*) do dir /b /ad "%%F" | findstr "^" >nul || copy "c:\licence.bin" "%%F" >nul
If you truly mean empty, (no files or folders), then remove the /ad option from the dir command
Dave Benham