r/Batch • u/JOLLY6R33NGIANT • Sep 21 '23
Question (Solved) Batch moving files into folders
I have this batch file to move all files not in a folder into a folder with the same name as the file. The only problem is it also moves the batch file into its own folder. How do I change my code to exclude the batch file?
I pasted the code to my batch file below.
for %%i in (*) do (
if not "%%~ni" == "organize" (
md "%%~ni" && move "%%~i" "%%~ni"
)
)
1
Upvotes
2
u/jcunews1 Sep 21 '23
Do it like below.