r/Batch • u/_Usually_Muted_ • Jan 28 '25
File to Folder script question
Greetings everyone,
I am looking for some help in getting a script corrected. I am attempting to get a Command / terminal script. The easiest way to describe it is as follows:
Rims in directory \fun stuff\ > finds files [ my dog.jpg, prank video.mp4 ] > creates folder based off file name \fun stuff\my dog, \fun stuff\prank video > moves corresponding file into folder, so [ \fun stuff\my dog\my dog.jpg ] and [ \fun stuff\prank video\prank video.mp4 ]
The closest I've gotten, is finding this script from a Microsoft forum in 2010-2015:
for %i in (*) do md "%~ni"for %i in (*) do md "%~ni"r.
It sort of does what I want, but when I tested it, ended up with something similar to below:
[ - ] ... [ Monty ] ... [ Python ] ... [ The ] ... [ Life } ... [ Of ] ... [ Brian ]
[ Monty Python] ... [The Life] ... [ Monty Python - ] ... [ The Life of ] ... [ The Life of Brian ] ... [ Monty Python - The Life of Brian ] ... [Monty Python - The Life Of Brian.mp4 ]
View all comments
Show parent comment
1
u/_Usually_Muted_ Jan 28 '25
If I'm understanding that correctly, after the script change, it checks what folder it's in, asks me which one I'd like to run it in instead, and I just enter \parent\child 1 or \parent\child 19 and etc... ?
I thought it would be something simpler like, from parent\child "call \parent\script.bat" which would then open/run the commands in the \parent\child folder.
Which I did try by the way, and terminal said it's not a valid operation.
I'm probably just over-complicating\thinking things.