I am also looking for something similar but couldn't find one that works for me. Tried @MC ND's but couldn't get it to work on a fresh install of W11 24H2 (OS Build 26100.3476); it just exits even if there was only a single line of text copied to the clipboard and also after removing:
:: Where to create the folder should come from contextual menu as parameter
if "%~1"=="" exit /b 1
if not exist "%~1" exit /b
I came up with a partial solution to my own problem that may be of help to anyone looking for an answer but w/ several caveats:
Here's the CB2Folder.bat
:
@echo off
cd /d "%~1" >nul 2>&1
setlocal enabledelayedexpansion
:: Save the clipboard content into a temporary file
for /f "delims=" %%a in ('powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()"') do echo %%a >> temp_clipboard.txt
:: Loop through the file and create a folder for each line (splitted by newlines)
for /f "delims=" %%b in (temp_clipboard.txt) do (
if not "%%b"=="" (
echo Creating folder: %%b
mkdir "%%b"
)
)
:: Clean up the temporary file
del temp_clipboard.txt
To add to the context menu of a folder (will create the folders inside the selected folder) and shell (will create the folders in the current folder), move the batch script to C:\Scripts\
and save the below as a .reg file and run it.
Note: In the .reg file, the filename of the batch file CB2Folder.bat
should be changed to whatever its filename is.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\RunCB2Folder]
@="Run CB2Folder in here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\RunCB2Folder\command]
@="\"C:\\Scripts\\CB2Folder.bat\""
[HKEY_CLASSES_ROOT\Directory\shell\RunCB2Folder]
@="Run CB2Folder in here"
[HKEY_CLASSES_ROOT\Directory\shell\RunCB2Folder\command]
@="\"C:\\Scripts\\CB2Folder.bat\" \"%1\""