1.

Solve : create a file inside number of folders.?

Answer»

Hello every one 

I have a question , i tried to create a FILE with name test.mk in side number of folders.
And i m not successful in that can any one helps me in that , i use batch programing for that.

example :
name of the file want to create : test.mk

Locations :
c:\first
c:\second
c:\third
c:\four

I need to create a file with same name in 116 location that's y i want a script to create it.

Thanks for any help .Seeing how your directories are top level folders on the C: drive, and don't seem to follow any specific naming convention, I WOULD run a dir list on the c: drive, cut and paste the 116 directory names into notepad and then do some fancy search and replace operations.

What is test.mk? Does it contain data to be copied into each directory, or is this just dummy label?

More info is probably needed test.mk is a name of the dummy(blank) file which i need to be created inside the folders .

by the way the problem is solved , i use Perl script to solve it.

following 2 scripts works:
Quote

Script 1(we run this script and it calls second script)
Code: [Select]FILES= ("c:\first",
"c:\second",
"c:\third"'
"c:\four");
for $file(files)
{
    system("C:/Perl/bin/perl C:/script_two.pl $file");
}
Quote
script_two(it creates a blank file inside folders)
Code: [Select]use Fcntl; #The Module
use File::Find;
if($#ARGV != 0)
{
print "\nUsage: perl $0 <Root Directory>\n";
}
else
{
$dir = ARGV[0]; #The root directory given by the user
find(\&edits, $dir);
print "Success\n";
}
sub edits()
{
sysopen (FH, 'local.mk', O_CREAT, 0755);
close (FH);
}name each folder 1, 2, 3... and so on
use this code and replace ^name^ with the name of the file your TRYING to make

Code: [Select]echo off
set dirnum=0
:loop
if dirnum=116 echo done&pause&exit
set /a dirnum=%dirnum%+1
echo.>C:\%dirnum%\^name^
goto loop


Discussion

No Comment Found