goocreations
goocreations

Reputation: 3066

Windows batch script for copying files to folder

I was able to do this in Linux, but Windows batch script is a lot different, hope someone can help me. I have a folder with a couple 100 files. I want a batch script that creates a folder for each of these files with the same name, but without the extension (eg: sheet1.xls will create a folder named sheet1).

After that each file should to moved to its corresponding folder (eg: sheet1.xls -> create folder sheet1 -> move the xls file to sheet1 folder).

Can anyone help me out with this?

Upvotes: 3

Views: 1740

Answers (1)

Bali C
Bali C

Reputation: 31251

for %%a in (C:\folder\*.*) do (
md "%%~pna"
move "%%a" "%%~pna"
)

Upvotes: 3

Related Questions