topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday August 27, 2025, 12:14 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Files2Folder- move selected files into subfolder based on matched first word  (Read 173 times)

Jakov

  • Participant
  • Joined in 2024
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Hi,
Today, I googled for "new folder with selection" until I reached to Files2Folder
I would like to thank you for this amazing extension.
Also, I would like to add a suggestion or an option for the new version
In addition to the available options in the Files2Folder, another option may be "Move all selected items into subfolder based on matched first word" or based on matched first three letters "Move all selected items into subfolder based on matched first three letters" or can make radio button to choose between word or character according to matched number.
I previously made batch file for this purpose, but if will be happy if this option is also available in Files2Folder.
Here is batch codes to benefit from the idea
# Based on matched first word
@echo off
setlocal enabledelayedexpansion

rem Set the directory containing the files
set "source_directory=D:\New folder"

rem Iterate through each file in the directory
for %%F in ("%source_directory%\*") do (
    rem Extract the first word of the filename
    set "filename=%%~nF"
    for /f "tokens=1 delims=_" %%W in ("!filename!") do (
        set "first_word=%%W"
    )

    rem Create the destination folder if it doesn't exist
    if not exist "%source_directory%\!first_word!" (
        mkdir "%source_directory%\!first_word!"
    )

    rem Move the file to the corresponding folder
    move "%%F" "%source_directory%\!first_word!\" > nul
)

echo Files moved into folders successfully.
pause
# Based on matched three letters
@echo off
setlocal enabledelayedexpansion

rem Set the directory containing the files
set "source_directory=D:\New folder"

rem Iterate through each file in the directory
for %%F in ("%source_directory%\*") do (
    rem Extract the first two letters of the filename
    set "filename=%%~nF"
    set "first_three_letters=!filename:~0,3!"

    rem Create the destination folder if it doesn't exist
    if not exist "%source_directory%\!first_three_letters!" (
        mkdir "%source_directory%\!first_three_letters!"
    )

    rem Move the file to the corresponding folder
    move "%%F" "%source_directory%\!first_three_letters!\" > nul
)

echo Files moved into folders successfully.
pause

Thanks