Basically what I'm trying to do is create a folder from a filename, which this does:
for %%i in (*.png) do mkdir "%%~ni"
After folder creation I'd like move a folder into this new folder.
move "other_folder" %%~ni
Basically what I'm trying to do is create a folder from a filename, which this does:
for %%i in (*.png) do mkdir "%%~ni"
After folder creation I'd like move a folder into this new folder.
move "other_folder" %%~ni
Based on your now completely changed question:
If there was only one .png file in the working directory, then you could simply do it in one line at the Command Prompt:
For %A In ("*.png") Do RoboCopy "other_folder" "%~nA" /E /MOVE >Nul However, if you think about it, once the other_folder has been moved the first time, it is no longer there to be moved again! You would therefore need to instead copy it, then after all .png files have been processed, remove other_folder.
At the Command Prompt: (two different commands, the first copies, the second removes)
For %A In ("*.png") Do RoboCopy "other_folder" "%~nA" /E > Nul RD /S /Q "other_folder" Similarly from a batch file:
@For %%A In ("*.png") Do @RoboCopy "other_folder" "%%~nA" /E > Nul @RD /S /Q "other_folder" Just take account that if anything goes wrong, (e.g. all of the content of other_folder doesn't copy), and you remove other_folder, you've lost that content.
Based on your title request, the bellow script will create a folder named after each *.png in the directory then move the matching file into the newly created file.
Batch:
for %%i in (*.png) do (mkdir "%%~ni" && move %%i %%~ni) Command Prompt:
for %i in (*.png) do (mkdir "%~ni" && move %i %~ni) "%~ni"%%i to your folder name/source directory. ex: move "source dir" "%%~ni"Thanks everybody I was able to figure it out
for %%i in (*.png) do mkdir "%%~ni" && move "folder" "%%~ni"
.png file in the current directory.