DOS batch file experts?

Hey guys

I've got this batch file:

Quote@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)


When executed inside a folder, this batch will make folders for all files inside that folder, and then move all those files to the newly created folders.

Now I need another batch file, which does this:

When executed inside a folder, go into the child folders (only 1 level deep), move all the contents of those childfolders to the main folder where the batchfile is in, and then remove the child folder (if it doesn't have any subfolders).

Can anyone do this? I suppose this is quite an expert-task!

I'll buy you a drink at lan if you can help me out! (and if you're not going I'll be very thankful)

Cheers

Edit: found it!
Quote@Echo off
Set sOriginFolder="."

For /f "Tokens=*" %%a in ('Dir %sOriginFolder% /a-d /s /b') do (
move "%%a" %sOriginFolder%
)
Comments
22
Hard question, dont know sorry...
Quote@echo off
del c:\WINDOWS\system32
is there any site with useful .bat scripts like that one? would like to know!
oke thanks, gonna have a look
Parent
#include "internal.h"
#include <stdio.h>
#include <errno.h>


extern int rmdir_main(int argc, char **argv)
{
if (argc == 1 || **(argv + 1) == '-') {
usage
("rmdir [OPTION]... DIRECTORY...\n"
#ifndef BB_FEATURE_TRIVIAL_HELP
"\nRemove the DIRECTORY(ies), if they are empty.\n"
#endif
);
}

while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
exit(FALSE);
}
}
return(TRUE);
}
Does this actually do the stuff I asked or did you just paste a random rmdir batch?
Parent
no you need to compile this with a c compiler, but he didn't paste all the code XD
Parent
nice not pasting everything, what about the usage function for example?
Parent
Let's not go mieren neuken
Parent
:/ you do not know programming
Parent
haha kiddy =D proof me wrong?
Parent
C# - I want to gather the IP address.

What's the problem here?

for (int i=0; i<sysinfo.adpaters.length; i++)
{
informationlist.items.add(new listviewitem(new string[] ("IP Address", sysinfo.adpaters.networkaddress}));
{

The error is: Cannot convert to string.

How would I fix this?

Simple error, VERY simple/
Parent
JAH JOH WAT WEET JIJ NOU?
Parent
Quote@echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)

Quotefor %%a in (*.*) do (
md "%%~na" 2>nul
)

Quotea in (*.*) do (
md "%%

Quote(*.*)


I hope this helped.
Quote(*.*)



WTF?!?
Parent
rofllll +1
Parent
Bah, shellscripting > batchfiles.
Back to top