batch to create files

Microsoft Windows server 2003 enterprise
January 6, 2010 at 23:04:47
Specs: Windows XP
hello guys ,
i have a batch that copy files from one dir to another with different extention.

%1 - is the full filename path i get from another program that runs the batch.

cd %~p1 (gets into the relevant directory)
copy *.* d:\bhub\chk\*.chk

this works fine , and also copies files that have no extention and creates for them *.chk.

now i want the same thing but i want to create the new *.chk files based on names only and that they will be 1 kb only. (with echo)

so i tried this and it doesn work for me (it works only when i type it but not when i run the batch)

cd %~p1
for %i in (*.*) do echo > d:\bhub\chk\%~ni.chk

and ideas?

See More: batch to create files

Report •

January 6, 2010 at 23:32:14
i assume you are adding the extra percent? can't see any other reason for the failure betwixt cmdline and script.

cd %~p1
for %i in (*.*) do echo > d:\bhub\chk\%~ni.chk

cd %%~p1
for %%i in (*.*) do echo > d:\bhub\chk\%%~ni.chk

i'm not being derogatory. this is only thing i can see, worked over here.

Report •

January 6, 2010 at 23:45:35
no its ok , im new to batch's .

I know its a noob question , but what does the second % do ?

Report •

January 7, 2010 at 12:28:40
It makes it work, that's what it does! =)

With the FOR command, you need a double percent for variables
in batch files, but not when you execute the command directly.
That's just how it is.

Report •

Related Solutions

Ask Question